├── .actionScriptProperties ├── .flexLibProperties ├── .gitignore ├── .project ├── Icon.png ├── README.markdown ├── bin └── flex-extensions.swc ├── build ├── build.properties └── build.xml ├── lib ├── Degrafa_Beta3.2_Flex3.swc └── hamcrest-as3-flex-1.1.3.swc ├── misc └── SourceMateMetadataConfig.xml └── src ├── asset ├── image │ ├── cursor │ │ ├── CursorAsset.as │ │ ├── grab.png │ │ ├── grabbing.png │ │ ├── resize-column.png │ │ ├── resize-row.png │ │ ├── zoom-in.png │ │ └── zoom-out.png │ └── search │ │ ├── SearchAsset.as │ │ ├── busy.png │ │ ├── clearSearch.png │ │ └── search.png └── skin │ └── slider │ ├── BackgroundSkin.mxml │ ├── HandleSkin.mxml │ ├── ThumbSkin.mxml │ └── grip-pattern.png ├── com └── codecatalyst │ ├── component │ ├── AbstractFacelessComponent.as │ ├── Button.as │ ├── OverlappingTabBar.as │ ├── Search.mxml │ ├── Tab.as │ ├── TabBar.as │ ├── behavior │ │ ├── AbstractBehavior.as │ │ ├── IBehavior.as │ │ └── ui │ │ │ ├── Populator.as │ │ │ ├── Popup.as │ │ │ ├── Selectable.as │ │ │ ├── Zoomer.mxml │ │ │ ├── events │ │ │ └── ContentEvent.as │ │ │ └── swap │ │ │ ├── Swapper.mxml │ │ │ ├── assets │ │ │ └── swapMode.gif │ │ │ └── events │ │ │ └── SwapperEvent.as │ ├── chart │ │ ├── DynamicAxisRenderer.as │ │ ├── DynamicChart.as │ │ ├── TruncatedAxisLabelRenderer.as │ │ ├── control │ │ │ ├── AbstractChartControl.as │ │ │ ├── ChartHoverControl.as │ │ │ ├── ChartHoverCrosshairControl.as │ │ │ ├── ChartHoverEvent.as │ │ │ ├── ChartPanControl.as │ │ │ ├── ChartPanEvent.as │ │ │ ├── ChartZoomEvent.as │ │ │ ├── ChartZoomInControl.as │ │ │ └── ChartZoomOutControl.as │ │ └── element │ │ │ ├── AbstractCartesianSeriesAnnotation.as │ │ │ ├── AbstractDateTimeAxisAnnotation.as │ │ │ ├── AnnotationLine.as │ │ │ ├── Background.as │ │ │ ├── DateTimeGridLineSet.as │ │ │ ├── DateTimeGridLines.as │ │ │ ├── HighlightedRegion.as │ │ │ └── LinearTrendLine.as │ ├── container │ │ └── BoxFrame.as │ ├── date │ │ ├── DateRangeInput.mxml │ │ ├── DateRangeSlider.as │ │ ├── DateRangeSliderEvent.as │ │ ├── DateRangeSliderThumb.as │ │ └── MonthPicker.mxml │ ├── renderer │ │ ├── BoxItemRenderer.as │ │ ├── CanvasItemRenderer.as │ │ ├── IContainerItemRenderer.as │ │ └── IItemRenderer.as │ ├── template │ │ ├── CheckGroup.mxml │ │ ├── Group.mxml │ │ ├── MasterDetail.as │ │ └── RadioGroup.mxml │ └── text │ │ ├── Label.as │ │ ├── Text.as │ │ └── UITextField.as │ ├── data │ ├── DateRange.as │ ├── FrequencyBin.as │ ├── NumericRange.as │ ├── Option.as │ ├── Property.as │ ├── SampleSet.as │ ├── TemporalData.as │ ├── TimeInterval.as │ └── enumeration │ │ ├── AbstractEnumeration.as │ │ ├── AbstractLabeledEnumeration.as │ │ └── IEnumeration.as │ ├── factory │ ├── ClassFactory.as │ ├── DataRendererFactory.as │ └── styleable │ │ ├── StyleableFactory.as │ │ └── StyleableRendererFactory.as │ ├── spark │ └── AnimatedNumericLabel.mxml │ └── util │ ├── ArrayUtil.as │ ├── AsyncTokenUtil.as │ ├── BitmapDataUtil.as │ ├── ClassUtil.as │ ├── CollectionViewUtil.as │ ├── ComparatorUtil.as │ ├── DateUtil.as │ ├── DelayedCall.as │ ├── DictionaryUtil.as │ ├── DisplayObjectContainerUtil.as │ ├── EventDispatcherUtil.as │ ├── FactoryPool.as │ ├── FormatUtil.as │ ├── GraphicsUtil.as │ ├── IObjectPool.as │ ├── ImageUtil.as │ ├── IterableUtil.as │ ├── KeyManager.as │ ├── LayoutCache.as │ ├── LayoutUtil.as │ ├── LogicUtil.as │ ├── MetadataUtil.as │ ├── MouseUtil.as │ ├── NumberUtil.as │ ├── PropertyUtil.as │ ├── RandomUtil.as │ ├── RectangleUtil.as │ ├── RuntimeEvaluationUtil.as │ ├── SampleSetUtil.as │ ├── SkinUtil.as │ ├── StatisticUtil.as │ ├── StringInflectionUtil.as │ ├── StyleUtil.as │ ├── XMLUtil.as │ ├── invalidation │ ├── InvalidationFlags.as │ ├── InvalidationTrackedProperty.as │ ├── InvalidationTracker.as │ └── mxml │ │ └── InvalidationTracker.as │ └── persistence │ ├── IKeyValueStore.as │ ├── KeyValueStoreAdapter.as │ └── PersistentObject.as ├── design.xml ├── manifest.xml ├── metadata.xml ├── qs ├── charts │ ├── DashedAreaRenderer.as │ └── DashedLineRenderer.as └── utils │ └── GraphicsUtils.as └── utils ├── display └── bringToFront.as └── number └── clamp.as /.actionScriptProperties: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | .settings 4 | bin-debug 5 | html-template 6 | 7 | /bin/flex-extensions.swc Folder/ -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | flex-extensions 4 | 5 | 6 | 7 | 8 | 9 | com.adobe.flexbuilder.project.flexbuilder 10 | 11 | 12 | 13 | 14 | 15 | com.adobe.flexbuilder.project.flexlibnature 16 | com.adobe.flexbuilder.project.actionscriptnature 17 | 18 | 19 | -------------------------------------------------------------------------------- /Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/Icon.png -------------------------------------------------------------------------------- /bin/flex-extensions.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/bin/flex-extensions.swc -------------------------------------------------------------------------------- /build/build.properties: -------------------------------------------------------------------------------- 1 | # Versioning 2 | 3 | lib.version = v1.0.0 4 | lib.name = Flex-Extensions-${lib.version} 5 | lib.namespace = http://fe.codecatalyst.com/2011/flex-extensions 6 | 7 | 8 | # Compiler 9 | 10 | flex.config = ${basedir}/build/lib2ant-flex-config.xml 11 | compiler.additional.args = -locale en_US -keep-as3-metadata+=Invalidate 12 | 13 | # CONFIG::FLEX3, CONFIG::FLEX4 14 | define.FLEX3 = false 15 | define.FLEX4 = true 16 | 17 | # Directories 18 | 19 | asdoc.templates.loc = /Users/thomasburleson/Documents/dev/asdocs/template 20 | flex3.sdk.loc = /Developer/Applications/FlashBuilder/sdks/3.5.0 21 | flex4.sdk.loc = /Developer/Applications/FlashBuilder/sdks/4.1.0 22 | 23 | src.loc = ${basedir}/src 24 | libs.loc = ${basedir}/lib 25 | 26 | bin.loc = ${basedir}/bin 27 | dist.loc = ${basedir}/dist 28 | doc.loc = ${basedir}/dist/doc 29 | -------------------------------------------------------------------------------- /lib/Degrafa_Beta3.2_Flex3.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/lib/Degrafa_Beta3.2_Flex3.swc -------------------------------------------------------------------------------- /lib/hamcrest-as3-flex-1.1.3.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/lib/hamcrest-as3-flex-1.1.3.swc -------------------------------------------------------------------------------- /misc/SourceMateMetadataConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/asset/image/cursor/CursorAsset.as: -------------------------------------------------------------------------------- 1 | package asset.image.cursor 2 | { 3 | public class CursorAsset 4 | { 5 | [Embed(source="/asset/image/cursor/grab.png")] 6 | /** 7 | * 'Grab' cursor. 8 | */ 9 | public static const GRAB:Class; 10 | 11 | [Embed(source="/asset/image/cursor/grabbing.png")] 12 | /** 13 | * 'Grabbing' cursor. 14 | */ 15 | public static const GRABBING:Class; 16 | 17 | [Embed(source="/asset/image/cursor/resize-column.png")] 18 | /** 19 | * 'Resize Column' cursor. 20 | */ 21 | public static const RESIZE_COLUMN:Class; 22 | 23 | [Embed(source="/asset/image/cursor/resize-row.png")] 24 | /** 25 | * 'Resize Row' cursor. 26 | */ 27 | public static const RESIZE_ROW:Class; 28 | 29 | [Embed(source="/asset/image/cursor/zoom-in.png")] 30 | /** 31 | * 'Zoom In' cursor. 32 | */ 33 | public static const ZOOM_IN:Class; 34 | 35 | [Embed(source="/asset/image/cursor/zoom-out.png")] 36 | /** 37 | * 'Zoom Out' cursor. 38 | */ 39 | public static const ZOOM_OUT:Class; 40 | } 41 | } -------------------------------------------------------------------------------- /src/asset/image/cursor/grab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/src/asset/image/cursor/grab.png -------------------------------------------------------------------------------- /src/asset/image/cursor/grabbing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/src/asset/image/cursor/grabbing.png -------------------------------------------------------------------------------- /src/asset/image/cursor/resize-column.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/src/asset/image/cursor/resize-column.png -------------------------------------------------------------------------------- /src/asset/image/cursor/resize-row.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/src/asset/image/cursor/resize-row.png -------------------------------------------------------------------------------- /src/asset/image/cursor/zoom-in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/src/asset/image/cursor/zoom-in.png -------------------------------------------------------------------------------- /src/asset/image/cursor/zoom-out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/src/asset/image/cursor/zoom-out.png -------------------------------------------------------------------------------- /src/asset/image/search/SearchAsset.as: -------------------------------------------------------------------------------- 1 | package asset.image.search 2 | { 3 | public class SearchAsset 4 | { 5 | [Embed(source="/asset/image/search/clearSearch.png")] 6 | /** 7 | * 'Clear' search icon. 8 | */ 9 | public static const SEARCH_CLEAR:Class; 10 | 11 | [Embed(source="/asset/image/search/search.png")] 12 | /** 13 | * 'Search For...' search icon. 14 | */ 15 | public static const SEARCH_FOR:Class; 16 | 17 | 18 | [Embed(source="/asset/image/search/busy.png")] 19 | /** 20 | * 'Busy searching...' icon. 21 | */ 22 | public static const SEARCH_BUSY:Class; 23 | 24 | } 25 | } -------------------------------------------------------------------------------- /src/asset/image/search/busy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/src/asset/image/search/busy.png -------------------------------------------------------------------------------- /src/asset/image/search/clearSearch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/src/asset/image/search/clearSearch.png -------------------------------------------------------------------------------- /src/asset/image/search/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/src/asset/image/search/search.png -------------------------------------------------------------------------------- /src/asset/skin/slider/BackgroundSkin.mxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/asset/skin/slider/HandleSkin.mxml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /src/asset/skin/slider/grip-pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/src/asset/skin/slider/grip-pattern.png -------------------------------------------------------------------------------- /src/com/codecatalyst/component/Button.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component 24 | { 25 | import mx.controls.Button; 26 | import mx.core.mx_internal; 27 | 28 | use namespace mx_internal; 29 | 30 | /** 31 | * Extends the standard Flex Halo Button control to support additional styles. 32 | */ 33 | public class Button extends mx.controls.Button 34 | { 35 | // ======================================== 36 | // Constructor 37 | // ======================================== 38 | 39 | /** 40 | * Constructor. 41 | */ 42 | public function Button() 43 | { 44 | super(); 45 | } 46 | 47 | // ======================================== 48 | // mx_internal methods 49 | // ======================================== 50 | 51 | /** 52 | * @inheritDoc 53 | */ 54 | override mx_internal function viewSkinForPhase( tempSkinName:String, stateName:String ):void 55 | { 56 | super.viewSkinForPhase( tempSkinName, stateName ); 57 | 58 | if ( selected ) 59 | { 60 | textField.setColor( getStyle( "textSelectedColor" ) ); 61 | } 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/Tab.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component 24 | { 25 | import com.codecatalyst.util.NumberUtil; 26 | 27 | import mx.controls.ButtonPhase; 28 | import mx.controls.tabBarClasses.Tab; 29 | import mx.core.mx_internal; 30 | 31 | use namespace mx_internal; 32 | 33 | /** 34 | * Text color of the label as the user moves the mouse pointer over the button while the button is selected. 35 | * 36 | * @default textRollOverColor 37 | */ 38 | [Style(name="textSelectedRollOverColor", type="uint", format="Color", inherit="yes")] 39 | 40 | /** 41 | * Vertical offset of the label while the tab is selected. 42 | */ 43 | [Style(name="selectedLabelVerticalOffset", type="Number", format="Length", inherit="no")] 44 | 45 | /** 46 | * Extends the standard Halo Tab component to add support for additional styles. 47 | */ 48 | public class Tab extends mx.controls.tabBarClasses.Tab 49 | { 50 | // ======================================== 51 | // Constructor 52 | // ======================================== 53 | 54 | /** 55 | * Constructor. 56 | */ 57 | public function Tab() 58 | { 59 | super(); 60 | } 61 | 62 | // ======================================== 63 | // Protected methods 64 | // ======================================== 65 | 66 | /** 67 | * @inheritDoc 68 | */ 69 | override mx_internal function layoutContents( unscaledWidth:Number, unscaledHeight:Number, offset:Boolean ):void 70 | { 71 | super.layoutContents(unscaledWidth, unscaledHeight, offset); 72 | 73 | if ( selected ) 74 | { 75 | var selectedLabelVerticalOffset:Number = NumberUtil.sanitizeNumber( getStyle( "selectedLabelVerticalOffset" ), 0 ) - 1; 76 | 77 | textField.y += selectedLabelVerticalOffset; 78 | 79 | if (currentIcon != null ) 80 | currentIcon.y += selectedLabelVerticalOffset; 81 | } 82 | } 83 | 84 | /** 85 | * @inheritDoc 86 | */ 87 | override mx_internal function viewSkinForPhase( tempSkinName:String, stateName:String ):void 88 | { 89 | super.viewSkinForPhase( tempSkinName, stateName ); 90 | 91 | if ( enabled && selected ) 92 | { 93 | if ( phase == ButtonPhase.OVER ) 94 | { 95 | var labelColor:Number = ( textField.getStyle( "textSelectedRollOverColor" ) != null ) ? textField.getStyle( "textSelectedRollOverColor" ) : textField.getStyle( "textRollOverColor" ); 96 | textField.setColor( labelColor ); 97 | } 98 | } 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/TabBar.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component 24 | { 25 | import mx.controls.TabBar; 26 | import mx.core.ClassFactory; 27 | import mx.core.mx_internal; 28 | 29 | use namespace mx_internal; 30 | 31 | /** 32 | * Extends the standard Halo TabBar to replace the standard Tab navigation item with a custom subclass. 33 | * 34 | * @see com.codecatalyst.component.Tab 35 | */ 36 | public class TabBar extends mx.controls.TabBar 37 | { 38 | // ======================================== 39 | // Constructor 40 | // ======================================== 41 | 42 | /** 43 | * Constructor. 44 | */ 45 | public function TabBar() 46 | { 47 | super(); 48 | 49 | navItemFactory = new ClassFactory( Tab ); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/behavior/AbstractBehavior.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.behavior 24 | { 25 | import com.codecatalyst.component.AbstractFacelessComponent; 26 | 27 | import mx.events.FlexEvent; 28 | 29 | [Event(name="updateComplete", type="mx.events.FlexEvent")] 30 | 31 | public class AbstractBehavior extends AbstractFacelessComponent implements IBehavior 32 | { 33 | // ======================================== 34 | // Constructor 35 | // ======================================== 36 | 37 | /** 38 | * Constructor. 39 | */ 40 | public function AbstractBehavior() 41 | { 42 | super(); 43 | } 44 | 45 | // ======================================== 46 | // Public methods 47 | // ======================================== 48 | 49 | /** 50 | * @inheritDoc 51 | */ 52 | override public function invalidateProperties():void 53 | { 54 | super.invalidateProperties(); 55 | 56 | // TODO: Add scheduling logic. 57 | // TODO: Move to AbstractFacelessComponent? 58 | 59 | validateNow(); 60 | } 61 | 62 | /** 63 | * @inheritDoc 64 | */ 65 | override public function validateNow():void 66 | { 67 | commitProperties(); 68 | 69 | dispatchEvent( new FlexEvent( FlexEvent.UPDATE_COMPLETE ) ); 70 | } 71 | 72 | // ======================================== 73 | // Protected methods 74 | // ======================================== 75 | 76 | /** 77 | * Processes the properties set on the component. 78 | */ 79 | protected function commitProperties():void 80 | { 81 | // Subclasses should override and implement this method. 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/behavior/IBehavior.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.behavior 24 | { 25 | import flash.events.IEventDispatcher; 26 | 27 | import mx.core.IMXMLObject; 28 | 29 | public interface IBehavior extends IMXMLObject, IEventDispatcher 30 | { 31 | } 32 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/behavior/ui/events/ContentEvent.as: -------------------------------------------------------------------------------- 1 | package com.codecatalyst.component.behavior.ui.events 2 | { 3 | import flash.events.Event; 4 | 5 | public class ContentEvent extends Event 6 | { 7 | 8 | public static const CONTENT_CHANGE : String = "contentChange"; 9 | public static const CONTENT_INITIALIZED : String = "contentInitialized"; 10 | public static const CONTENT_READY : String = "contentReady"; 11 | public static const CONTENT_RELEASED : String = "contentReleased"; 12 | 13 | public var content : Object; 14 | 15 | 16 | public function ContentEvent(type:String, content:Object=null) 17 | { 18 | super(type,false,false); 19 | this.content = content; 20 | } 21 | 22 | override public function clone():Event 23 | { 24 | return new ContentEvent(type, content); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/behavior/ui/swap/assets/swapMode.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CC-Archived/flex-extensions/37f9c221f5bc67185c7a74a6492cc8f1091cb7b5/src/com/codecatalyst/component/behavior/ui/swap/assets/swapMode.gif -------------------------------------------------------------------------------- /src/com/codecatalyst/component/behavior/ui/swap/events/SwapperEvent.as: -------------------------------------------------------------------------------- 1 | package com.codecatalyst.component.behavior.ui.swap.events 2 | { 3 | import flash.events.Event; 4 | 5 | import mx.core.UIComponent; 6 | 7 | public class SwapperEvent extends Event 8 | { 9 | static public var STARTED : String = "swapStarted"; 10 | static public var SWAPPED : String = "swapPerformed"; 11 | static public var FINISHED : String = "swapFinished"; 12 | 13 | public var source : UIComponent = null; 14 | public var dest : UIComponent = null; 15 | public var allItems : Array = []; 16 | 17 | public function SwapperEvent(type:String, source:UIComponent, dest:UIComponent=null, items:Array=null) 18 | { 19 | super(type, true, true); 20 | this.source = source; 21 | this.dest = dest; 22 | this.allItems = items==null ? [] : items; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/chart/DynamicAxisRenderer.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.chart 24 | { 25 | import mx.charts.AxisRenderer; 26 | 27 | public class DynamicAxisRenderer extends AxisRenderer 28 | { 29 | // ======================================== 30 | // Constructor 31 | // ======================================== 32 | 33 | /** 34 | * Constructor. 35 | */ 36 | public function DynamicAxisRenderer() 37 | { 38 | super(); 39 | } 40 | 41 | // ======================================== 42 | // Protected methods 43 | // ======================================== 44 | 45 | /** 46 | * @inheritDoc 47 | */ 48 | override protected function updateDisplayList( unscaledWidth:Number, unscaledHeight:Number ):void 49 | { 50 | // Workaround for NPE where an AxisRenderer instance has been removed from the chart but still has a 51 | // deferred invalidation of its display list still outstanding, causing a null pointer exception. 52 | 53 | if ( chart == null ) 54 | return; 55 | 56 | super.updateDisplayList( unscaledWidth, unscaledHeight ); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/chart/DynamicChart.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.chart 24 | { 25 | import mx.charts.AxisRenderer; 26 | import mx.charts.LinearAxis; 27 | import mx.charts.chartClasses.CartesianChart; 28 | import mx.core.mx_internal; 29 | 30 | public class DynamicChart extends CartesianChart 31 | { 32 | // ======================================== 33 | // Constructor 34 | // ======================================== 35 | 36 | /** 37 | * Constructor. 38 | */ 39 | public function DynamicChart() 40 | { 41 | super(); 42 | } 43 | 44 | // ======================================== 45 | // Protected properties 46 | // ======================================== 47 | 48 | /** 49 | * Returns the Flex version. 50 | */ 51 | protected function get mx_version():Number 52 | { 53 | var matches:Object = /^([\d]+.[\d]+).(.*)$/.exec( mx_internal::VERSION ); 54 | 55 | return ( matches.length > 1 ) ? Number( matches[ 1 ] ) : 0; 56 | } 57 | 58 | // ======================================== 59 | // Protected methods 60 | // ======================================== 61 | 62 | /** 63 | * @inheritDoc 64 | */ 65 | override protected function commitProperties():void 66 | { 67 | // Only applies to Flex SDK versions < 4.5 - horizontalAxisRenderer, verticalAxisRenderer (and this bug) were removed in subsequent versions. 68 | 69 | if ( mx_version < 4.5 ) 70 | { 71 | var horizontalAxisRenderer:AxisRenderer = this[ "horizontalAxisRenderer" ] as AxisRenderer; 72 | var verticalAxisRenderer:AxisRenderer = this[ "verticalAxisRenderer" ] as AxisRenderer; 73 | 74 | // Workaround for bug in CartesianChart where the deprecated horizontalAxisRenderer and verticalAxisRenderer 75 | // properties are internally populated by CartesianChart and are not cleared when horizontalAxisRenderers or verticalAxisRenderers 76 | // are later dynamically populated. 77 | 78 | if ( ( horizontalAxisRenderers.length == 0 ) && ( horizontalAxisRenderer == null ) ) 79 | { 80 | horizontalAxisRenderers = [ createTemporaryAxisRenderer() ]; 81 | } 82 | 83 | if ( ( verticalAxisRenderers.length == 0 ) && ( verticalAxisRenderer == null ) ) 84 | { 85 | verticalAxisRenderers = [ createTemporaryAxisRenderer() ]; 86 | } 87 | } 88 | 89 | super.commitProperties(); 90 | } 91 | 92 | /** 93 | * Create a temporary AxisRenderer. 94 | */ 95 | protected function createTemporaryAxisRenderer():AxisRenderer 96 | { 97 | var axisRenderer:AxisRenderer = new AxisRenderer(); 98 | 99 | axisRenderer.axis = new LinearAxis(); 100 | 101 | return axisRenderer; 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/chart/TruncatedAxisLabelRenderer.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.chart 24 | { 25 | import com.codecatalyst.component.text.Label; 26 | 27 | import mx.charts.AxisLabel; 28 | 29 | public class TruncatedAxisLabelRenderer extends Label 30 | { 31 | // ======================================== 32 | // Constructor 33 | // ======================================== 34 | 35 | /** 36 | * Constructor. 37 | */ 38 | public function TruncatedAxisLabelRenderer() 39 | { 40 | super(); 41 | 42 | truncateToFit = true; 43 | } 44 | 45 | // ======================================== 46 | // Public properties 47 | // ======================================== 48 | 49 | /** 50 | * @inheritDoc 51 | */ 52 | override public function set data( value:Object ):void 53 | { 54 | super.data = value; 55 | 56 | if ( value is AxisLabel ) 57 | { 58 | text = ( value as AxisLabel ).text; 59 | } 60 | else 61 | { 62 | text = value as String; 63 | } 64 | } 65 | 66 | // ======================================== 67 | // Protected methods 68 | // ======================================== 69 | 70 | /** 71 | * @inheritDoc 72 | */ 73 | override protected function measure():void 74 | { 75 | super.measure(); 76 | 77 | measuredWidth = width; 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/chart/control/ChartHoverCrosshairControl.as: -------------------------------------------------------------------------------- 1 | package com.codecatalyst.component.chart.control 2 | { 3 | import com.codecatalyst.util.GraphicsUtil; 4 | 5 | import flash.geom.Point; 6 | 7 | import mx.graphics.IStroke; 8 | import mx.graphics.Stroke; 9 | 10 | /** 11 | * Orientation. 12 | */ 13 | [Style(name="orientation", type="String", enumeration="horizontal,vertical,both", inherit="no")] 14 | 15 | /** 16 | * Stroke. 17 | */ 18 | [Style(name="stroke", type="mx.graphics.IStroke", inherit="no")] 19 | 20 | /** 21 | * Dash pattern (optional). 22 | */ 23 | [Style(name="pattern", type="Array", arrayType="Number")] 24 | 25 | public class ChartHoverCrosshairControl extends ChartHoverControl 26 | { 27 | // ======================================== 28 | // Constructor 29 | // ======================================== 30 | 31 | /** 32 | * Constructor. 33 | */ 34 | public function ChartHoverCrosshairControl() 35 | { 36 | super(); 37 | } 38 | 39 | // ======================================== 40 | // Protected methods 41 | // ======================================== 42 | 43 | /** 44 | * Draw a hover indicator at the specified point. 45 | */ 46 | override protected function drawHoverIndicatorForPoint( point:Point ):void 47 | { 48 | var orientation:String = getStyle( "orientation" ) as String || "both"; 49 | var stroke:IStroke = getStyle( "stroke" ) as IStroke || new Stroke( 0x000000, 1.0 ); 50 | var pattern:Array = getStyle( "pattern" ) as Array; 51 | 52 | switch ( orientation ) 53 | { 54 | case "horizontal": 55 | drawLine( new Point( 0, point.y ), new Point( width, point.y ), stroke, pattern ); 56 | break; 57 | 58 | case "vertical": 59 | drawLine( new Point( point.x, 0 ), new Point( point.x, height ), stroke, pattern ); 60 | break; 61 | 62 | case "both": 63 | default: 64 | drawLine( new Point( point.x, 0 ), new Point( point.x, height ), stroke, pattern ); 65 | drawLine( new Point( 0, point.y ), new Point( width, point.y ), stroke, pattern ); 66 | break; 67 | } 68 | } 69 | 70 | /** 71 | * Draw a line between the specified starting and ending Points. 72 | */ 73 | protected function drawLine( start:Point, end:Point, stroke:IStroke, pattern:Array ):void 74 | { 75 | GraphicsUtil.drawPolyLine( graphics, [ start, end ], stroke, pattern ); 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/chart/control/ChartHoverEvent.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.chart.control 24 | { 25 | import flash.events.Event; 26 | import flash.geom.Point; 27 | 28 | public class ChartHoverEvent extends Event 29 | { 30 | // ======================================== 31 | // Public constants 32 | // ======================================== 33 | 34 | /** 35 | * Hover. 36 | * 37 | * @see #x 38 | * @see #y 39 | */ 40 | public static const HOVER:String = "hover"; 41 | 42 | // ======================================== 43 | // Public properties 44 | // ======================================== 45 | 46 | /** 47 | * X value. 48 | */ 49 | public var x:*; 50 | 51 | /** 52 | * Y value. 53 | */ 54 | public var y:*; 55 | 56 | // ======================================== 57 | // Constructor 58 | // ======================================== 59 | 60 | /** 61 | * Constructor. 62 | */ 63 | public function ChartHoverEvent( type:String, bubbles:Boolean = false, cancelable:Boolean = false ) 64 | { 65 | super( type, bubbles, cancelable ); 66 | } 67 | 68 | // ======================================== 69 | // Public methods 70 | // ======================================== 71 | 72 | /** 73 | * Duplicates an instance of the event to support re-dispatching. 74 | */ 75 | override public function clone():Event 76 | { 77 | var event:ChartHoverEvent = new ChartHoverEvent( type, bubbles, cancelable ); 78 | 79 | event.x = x; 80 | event.y = y; 81 | 82 | return event; 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/chart/control/ChartPanEvent.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.chart.control 24 | { 25 | import flash.events.Event; 26 | 27 | public class ChartPanEvent extends Event 28 | { 29 | // ======================================== 30 | // Public constants 31 | // ======================================== 32 | 33 | /** 34 | * Pan. 35 | * 36 | * @see #xAxisDelta 37 | * @see #yAxisDelta 38 | */ 39 | public static const PAN:String = "pan"; 40 | 41 | // ======================================== 42 | // Public properties 43 | // ======================================== 44 | 45 | /** 46 | * X axis delta. 47 | */ 48 | public var xAxisDelta:Number = NaN; 49 | 50 | /** 51 | * Y axis delta. 52 | */ 53 | public var yAxisDelta:Number = NaN; 54 | 55 | /** 56 | * Indicates whether this panning interaction is 'complete'. 57 | */ 58 | public var complete:Boolean = false; 59 | 60 | // ======================================== 61 | // Constructor 62 | // ======================================== 63 | 64 | /** 65 | * Constructor. 66 | */ 67 | public function ChartPanEvent( type:String, bubbles:Boolean = false, cancelable:Boolean = false ) 68 | { 69 | super( type, bubbles, cancelable ); 70 | } 71 | 72 | // ======================================== 73 | // Public methods 74 | // ======================================== 75 | 76 | /** 77 | * Duplicates an instance of the event to support re-dispatching. 78 | */ 79 | override public function clone():Event 80 | { 81 | var event:ChartPanEvent = new ChartPanEvent( type, bubbles, cancelable ); 82 | 83 | event.xAxisDelta = xAxisDelta; 84 | event.yAxisDelta = yAxisDelta; 85 | event.complete = complete; 86 | 87 | return event; 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/chart/control/ChartZoomEvent.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.chart.control 24 | { 25 | import flash.events.Event; 26 | import flash.geom.Point; 27 | import flash.geom.Rectangle; 28 | 29 | public class ChartZoomEvent extends Event 30 | { 31 | // ======================================== 32 | // Public constants 33 | // ======================================== 34 | 35 | /** 36 | * Zoom in. 37 | * 38 | * @see #point 39 | */ 40 | public static const ZOOM_IN:String = "zoomIn"; 41 | 42 | /** 43 | * Zoom out. 44 | * 45 | * @see #point 46 | */ 47 | public static const ZOOM_OUT:String = "zoomOut"; 48 | 49 | /** 50 | * Zoom to a rectangle. 51 | * 52 | * @see #rectangle 53 | */ 54 | public static const ZOOM_TO_RECTANGLE:String = "zoomToRectangle"; 55 | 56 | // ======================================== 57 | // Public properties 58 | // ======================================== 59 | 60 | /** 61 | * Zoom origin point. 62 | */ 63 | public var origin:Point = null; 64 | 65 | /** 66 | * Zoom rectangle. 67 | */ 68 | public var rectangle:Rectangle = null; 69 | 70 | // ======================================== 71 | // Constructor 72 | // ======================================== 73 | 74 | /** 75 | * Constructor. 76 | */ 77 | public function ChartZoomEvent( type:String, bubbles:Boolean = false, cancelable:Boolean = false ) 78 | { 79 | super( type, bubbles, cancelable ); 80 | } 81 | 82 | // ======================================== 83 | // Public methods 84 | // ======================================== 85 | 86 | /** 87 | * Duplicates an instance of the event to support re-dispatching. 88 | */ 89 | override public function clone():Event 90 | { 91 | var event:ChartZoomEvent = new ChartZoomEvent( type, bubbles, cancelable ); 92 | 93 | event.origin = origin; 94 | event.rectangle = rectangle; 95 | 96 | return event; 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/chart/element/AbstractCartesianSeriesAnnotation.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.chart.element 24 | { 25 | import flash.events.Event; 26 | 27 | import mx.charts.chartClasses.CartesianDataCanvas; 28 | import mx.charts.chartClasses.Series; 29 | import mx.events.FlexEvent; 30 | 31 | public class AbstractCartesianSeriesAnnotation extends CartesianDataCanvas 32 | { 33 | // ======================================== 34 | // Protected properties 35 | // ======================================== 36 | 37 | /** 38 | * Backing variable for series property. 39 | * 40 | * @see #series 41 | */ 42 | protected var _series:Series; 43 | 44 | [ArrayElementType("mx.chart.ChartItem")] 45 | /** 46 | * ChartItems for series. 47 | */ 48 | protected function get chartItems():Array 49 | { 50 | if ( ( series != null ) && ( series.items != null ) ) 51 | return series.items; 52 | 53 | return []; 54 | } 55 | 56 | /** 57 | * ChartItem item x value field. 58 | */ 59 | protected function get xField():String 60 | { 61 | try 62 | { 63 | return series[ "xField" ]; 64 | } 65 | catch ( error:Error ) 66 | { 67 | throw new Error( "Unsupported Series type." ); 68 | } 69 | 70 | return null; 71 | } 72 | 73 | /** 74 | * ChartItem item y value field. 75 | */ 76 | protected function get yField():String 77 | { 78 | try 79 | { 80 | return series[ "yField" ]; 81 | } 82 | catch ( error:Error ) 83 | { 84 | throw new Error( "Unsupported Series type." ); 85 | } 86 | 87 | return null; 88 | } 89 | 90 | // ======================================== 91 | // Public properties 92 | // ======================================== 93 | 94 | [Bindable("seriesChanged")] 95 | /** 96 | * Series. 97 | */ 98 | public function get series():Series 99 | { 100 | return _series; 101 | } 102 | 103 | public function set series( value:Series ):void 104 | { 105 | if ( _series != value ) 106 | { 107 | if ( _series != null ) 108 | _series.addEventListener( FlexEvent.UPDATE_COMPLETE, series_updateCompleteHandler ); 109 | 110 | _series = value; 111 | 112 | if ( _series != null ) 113 | _series.addEventListener( FlexEvent.UPDATE_COMPLETE, series_updateCompleteHandler, false, 0, true ); 114 | 115 | dispatchEvent( new Event( "seriesChanged" ) ); 116 | } 117 | } 118 | 119 | // ======================================== 120 | // Constructor 121 | // ======================================== 122 | 123 | /** 124 | * Constructor 125 | */ 126 | public function AbstractCartesianSeriesAnnotation() 127 | { 128 | super(); 129 | 130 | percentWidth = 100; 131 | percentHeight = 100; 132 | } 133 | 134 | // ======================================== 135 | // Protected methods 136 | // ======================================== 137 | 138 | /** 139 | * Handle FlexEvent.UPDATE_COMPLETE. 140 | */ 141 | protected function series_updateCompleteHandler( event:FlexEvent ):void 142 | { 143 | invalidateDisplayList(); 144 | } 145 | } 146 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/chart/element/AbstractDateTimeAxisAnnotation.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.chart.element 24 | { 25 | import mx.charts.DateTimeAxis; 26 | import mx.charts.chartClasses.CartesianChart; 27 | import mx.charts.chartClasses.CartesianDataCanvas; 28 | 29 | public class AbstractDateTimeAxisAnnotation extends CartesianDataCanvas 30 | { 31 | // ======================================== 32 | // Protected constants 33 | // ======================================== 34 | 35 | /** 36 | * Vertical direction. 37 | */ 38 | protected static const VERTICAL:String = "vertical"; 39 | 40 | /** 41 | * Horizontal direction. 42 | */ 43 | protected static const HORIZONTAL:String = "horizontal"; 44 | 45 | // ======================================== 46 | // Protected properties 47 | // ======================================== 48 | 49 | /** 50 | * DateTimeAxis associated with the chart, if applicable. 51 | */ 52 | protected var dateTimeAxis:DateTimeAxis = null; 53 | 54 | /** 55 | * Direction of the DateTimeAxis (HORIZONTAL or VERTICAL). 56 | */ 57 | protected var dateTimeAxisDirection:String = null; 58 | 59 | // ======================================== 60 | // Constructor 61 | // ======================================== 62 | 63 | /** 64 | * Constructor. 65 | */ 66 | public function AbstractDateTimeAxisAnnotation() 67 | { 68 | super(); 69 | 70 | this.percentWidth = 100; 71 | this.percentHeight = 100; 72 | } 73 | 74 | // ======================================== 75 | // Protected properties 76 | // ======================================== 77 | 78 | /** 79 | * @inheritDoc 80 | */ 81 | override protected function commitProperties():void 82 | { 83 | super.commitProperties(); 84 | 85 | dateTimeAxis = getDateTimeAxis(); 86 | dateTimeAxisDirection = getDateTimeAxisDirection(); 87 | } 88 | 89 | /** 90 | * Returns the DateTimeAxis, or null if the parent chart does not have a DateTimeAxis. 91 | */ 92 | protected function getDateTimeAxis():DateTimeAxis 93 | { 94 | if ( horizontalAxis is DateTimeAxis ) 95 | return horizontalAxis as DateTimeAxis; 96 | 97 | if ( verticalAxis is DateTimeAxis ) 98 | return verticalAxis as DateTimeAxis; 99 | 100 | if ( chart is CartesianChart ) 101 | { 102 | var cartesianChart:CartesianChart = chart as CartesianChart; 103 | 104 | if ( cartesianChart.horizontalAxis is DateTimeAxis ) 105 | return cartesianChart.horizontalAxis as DateTimeAxis; 106 | 107 | if ( cartesianChart.verticalAxis is DateTimeAxis ) 108 | return cartesianChart.verticalAxis as DateTimeAxis; 109 | } 110 | 111 | return null; 112 | } 113 | 114 | /** 115 | * Returns the DateTimeAxis direction (HORIZONTAL or VERTICAL), or null if the parent chart does not have a DateTimeAxis. 116 | */ 117 | protected function getDateTimeAxisDirection():String 118 | { 119 | if ( horizontalAxis is DateTimeAxis ) 120 | return HORIZONTAL; 121 | 122 | if ( verticalAxis is DateTimeAxis ) 123 | return VERTICAL; 124 | 125 | if ( chart is CartesianChart ) 126 | { 127 | var cartesianChart:CartesianChart = chart as CartesianChart; 128 | 129 | if ( cartesianChart.horizontalAxis is DateTimeAxis ) 130 | return HORIZONTAL; 131 | 132 | if ( cartesianChart.verticalAxis is DateTimeAxis ) 133 | return VERTICAL; 134 | } 135 | 136 | return null; 137 | } 138 | } 139 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/chart/element/Background.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.chart.element 24 | { 25 | import flash.geom.Rectangle; 26 | 27 | import mx.charts.chartClasses.ChartElement; 28 | import mx.graphics.IFill; 29 | import mx.graphics.IStroke; 30 | import mx.graphics.SolidColor; 31 | import mx.graphics.Stroke; 32 | 33 | /** 34 | * Background fill. 35 | */ 36 | [Style(name="backgroundFill", type="mx.graphics.IFill", inherit="no")] 37 | 38 | /** 39 | * Border stroke. 40 | */ 41 | [Style(name="borderStroke", type="mx.graphics.IStroke", inherit="no")] 42 | 43 | public class Background extends ChartElement 44 | { 45 | // ======================================== 46 | // Constructor 47 | // ======================================== 48 | 49 | /** 50 | * Constructor. 51 | */ 52 | public function Background() 53 | { 54 | super(); 55 | 56 | percentWidth = 100; 57 | percentHeight = 100; 58 | } 59 | 60 | // ======================================== 61 | // Protected methods 62 | // ======================================== 63 | 64 | /** 65 | * @inheritDoc 66 | */ 67 | override protected function updateDisplayList( unscaledWidth:Number, unscaledHeight:Number ):void 68 | { 69 | super.updateDisplayList( unscaledWidth, unscaledHeight ); 70 | 71 | if ( chart == null ) 72 | return; 73 | 74 | // NOTE: ChartBase and CartesianChart incorrectly mask backgroundElements, so we just blow away the mask in the parent 'holder' component. 75 | parent.mask = null; 76 | 77 | var backgroundFill:IFill = getStyle( "backgroundFill" ) as IFill || new SolidColor( 0xffffff, 1.0 ); 78 | var borderStroke:IStroke = getStyle( "borderStroke" ) as IStroke || new Stroke( 0x000000, 1.0 ); 79 | 80 | var borderRectangle:Rectangle = new Rectangle( -1, -1, unscaledWidth + 1, unscaledHeight + 1 ); 81 | 82 | graphics.clear(); 83 | 84 | CONFIG::FLEX3 { 85 | borderStroke.apply( graphics ); 86 | backgroundFill.begin( graphics, borderRectangle ); 87 | } 88 | CONFIG::FLEX4 { 89 | borderStroke.apply( graphics, null, null ); 90 | backgroundFill.begin( graphics, borderRectangle, null ); 91 | } 92 | 93 | graphics.drawRect( borderRectangle.x, borderRectangle.y, borderRectangle.width, borderRectangle.height ); 94 | backgroundFill.end( graphics ); 95 | } 96 | } 97 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/chart/element/DateTimeGridLineSet.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.chart.element 24 | { 25 | import com.codecatalyst.data.TimeInterval; 26 | 27 | import flash.events.Event; 28 | import flash.events.EventDispatcher; 29 | 30 | [DefaultProperty("interval")] 31 | public class DateTimeGridLineSet extends EventDispatcher 32 | { 33 | // ======================================== 34 | // Protected properties 35 | // ======================================== 36 | 37 | /** 38 | * Backing variable for interval property. 39 | * 40 | * @see #interval 41 | */ 42 | protected var _interval:TimeInterval = null; 43 | 44 | /** 45 | * Backing variable for maximumTimeSpan property. 46 | * 47 | * @see #maximumTimeSpan 48 | */ 49 | protected var _maximumTimeSpan:Number = NaN; 50 | 51 | /** 52 | * Backing variable for strokeFilterFunction property. 53 | */ 54 | protected var _strokeFilterFunction:Function = null; 55 | 56 | /** 57 | * Backing variable for fillFilterFunction property. 58 | */ 59 | protected var _fillFilterFunction:Function = null; 60 | 61 | // ======================================== 62 | // Public properties 63 | // ======================================== 64 | 65 | [Bindable("intervalChanged")] 66 | /** 67 | * Time interval associated with this grid line set. 68 | */ 69 | public function get interval():TimeInterval 70 | { 71 | return _interval; 72 | } 73 | 74 | public function set interval( value:TimeInterval ):void 75 | { 76 | if ( _interval != value ) 77 | { 78 | _interval = value; 79 | 80 | dispatchEvent( new Event( "intervalChanged" ) ); 81 | } 82 | } 83 | 84 | [Bindable("maximumTimeSpanChanged")] 85 | /** 86 | * Maximum time span threshold, in milliseconds. 87 | */ 88 | public function get maximumTimeSpan():Number 89 | { 90 | return _maximumTimeSpan 91 | } 92 | 93 | public function set maximumTimeSpan( value:Number ):void 94 | { 95 | if ( _maximumTimeSpan != value ) 96 | { 97 | _maximumTimeSpan = value; 98 | 99 | dispatchEvent( new Event( "maximumTimeSpanChanged" ) ); 100 | } 101 | } 102 | 103 | [Bindable("strokeFilterFunctionChanged")] 104 | /** 105 | * Stroke filter function (optional). 106 | */ 107 | public function get strokeFilterFunction():Function 108 | { 109 | return _strokeFilterFunction; 110 | } 111 | 112 | public function set strokeFilterFunction( value:Function ):void 113 | { 114 | if ( _strokeFilterFunction != value ) 115 | { 116 | _strokeFilterFunction = value; 117 | 118 | dispatchEvent( new Event( "strokeFilterFunctionChanged" ) ); 119 | } 120 | } 121 | 122 | [Bindable("fillFilterFunctionChanged")] 123 | /** 124 | * Fill filter function (optional). 125 | */ 126 | public function get fillFilterFunction():Function 127 | { 128 | return _fillFilterFunction; 129 | } 130 | 131 | public function set fillFilterFunction( value:Function ):void 132 | { 133 | if ( _fillFilterFunction != value ) 134 | { 135 | _fillFilterFunction = value; 136 | 137 | dispatchEvent( new Event( "fillFilterFunctionChanged" ) ); 138 | } 139 | } 140 | 141 | // ======================================== 142 | // Constructor 143 | // ======================================== 144 | 145 | /** 146 | * Constructor. 147 | */ 148 | public function DateTimeGridLineSet( interval:TimeInterval = null, maximumTimeSpan:Number = NaN, strokeFilterFunction:Function = null, fillFilterFunction:Function = null ) 149 | { 150 | super(); 151 | 152 | this.interval = interval; 153 | this.maximumTimeSpan = maximumTimeSpan; 154 | this.strokeFilterFunction = strokeFilterFunction; 155 | this.fillFilterFunction = fillFilterFunction; 156 | } 157 | } 158 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/container/BoxFrame.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2009 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.container 24 | { 25 | import mx.containers.Box; 26 | 27 | public class BoxFrame extends Box 28 | { 29 | // ======================================== 30 | // Constructor 31 | // ======================================== 32 | 33 | /** 34 | * Constructor. 35 | */ 36 | public function BoxFrame() 37 | { 38 | super(); 39 | } 40 | 41 | // ======================================== 42 | // Protected methods 43 | // ======================================== 44 | 45 | /** 46 | * @inheritDoc 47 | */ 48 | override protected function measure() : void 49 | { 50 | // Prevent children from increasing the size of the container. 51 | 52 | measuredWidth = 0; 53 | measuredHeight = 0; 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/date/DateRangeSliderEvent.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2009 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.date 24 | { 25 | import com.codecatalyst.data.DateRange; 26 | 27 | import flash.events.Event; 28 | 29 | public class DateRangeSliderEvent extends Event 30 | { 31 | // ======================================== 32 | // Public constants 33 | // ======================================== 34 | 35 | /** 36 | * Notifies listeners that the DateRange was panned. 37 | * 38 | * @see #dateRange 39 | * @see #index 40 | * @see #complete 41 | */ 42 | public static const DATE_RANGE_PANNED:String = "dateRangePanned"; 43 | 44 | /** 45 | * Notifies listeners that the DateRange was resized. 46 | * 47 | * @see #dateRange 48 | * @see #index 49 | * @see #complete 50 | */ 51 | public static const DATE_RANGE_RESIZED:String = "dateRangeResized"; 52 | 53 | // ======================================== 54 | // Public properties 55 | // ======================================== 56 | 57 | /** 58 | * DateRange. 59 | */ 60 | public var dateRange:DateRange = null; 61 | 62 | /** 63 | * DateRange index. 64 | */ 65 | public var index:int = 0; 66 | 67 | /** 68 | * Indicates whether the user interaction is 'complete'. 69 | */ 70 | public var complete:Boolean = false; 71 | 72 | // ======================================== 73 | // Constructor 74 | // ======================================== 75 | 76 | /** 77 | * Constructor. 78 | */ 79 | public function DateRangeSliderEvent( type:String, bubbles:Boolean = false, cancelable:Boolean = false ) 80 | { 81 | super( type, bubbles, cancelable ); 82 | } 83 | 84 | // ======================================== 85 | // Public methods 86 | // ======================================== 87 | 88 | /** 89 | * Duplicates an instance of the event to support re-dispatching. 90 | */ 91 | override public function clone():Event 92 | { 93 | var event:DateRangeSliderEvent = new DateRangeSliderEvent( type, bubbles, cancelable ); 94 | 95 | event.dateRange = dateRange; 96 | event.index = index; 97 | event.complete = complete; 98 | 99 | return event; 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/renderer/IContainerItemRenderer.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2008 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.renderer 24 | { 25 | import mx.core.IContainer; 26 | 27 | public interface IContainerItemRenderer extends IContainer, IItemRenderer 28 | { 29 | } 30 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/renderer/IItemRenderer.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2008 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.renderer 24 | { 25 | import mx.controls.listClasses.BaseListData; 26 | import mx.controls.listClasses.IDropInListItemRenderer; 27 | import mx.controls.listClasses.IListItemRenderer; 28 | 29 | /** 30 | * Name of the class to use as the default skin for the background and border. 31 | * @default "mx.skins.halo.HaloBorder" 32 | */ 33 | [Style( name="borderSkin", type="Class", inherit="no", states="up, over, down, disabled, selectedUp, selectedOver, selectedDown, selectedDisabled" )] 34 | 35 | public interface IItemRenderer extends IListItemRenderer, IDropInListItemRenderer 36 | { 37 | [Bindable( "isMouseOverChanged" )] 38 | /** 39 | * Indicates whether the mouse is over this item. 40 | */ 41 | function get isMouseOver():Boolean; 42 | 43 | [Bindable( "isMouseDownChanged" )] 44 | /** 45 | * Indicates whether the mouse is down on this item. 46 | */ 47 | function get isMouseDown():Boolean; 48 | 49 | [Bindable( "isHighlightedChanged" )] 50 | /** 51 | * Indicates whether this item is highlighted. 52 | */ 53 | function get isHighlighted():Boolean; 54 | 55 | [Bindable( "isSelectedChanged" )] 56 | /** 57 | * Indicates whether this item is selected. 58 | */ 59 | function get isSelected():Boolean; 60 | } 61 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/template/CheckGroup.mxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | [DefaultProperty("itemRenderer")] 9 | 10 | /** 11 | * Dispatched when the user changes the selected item(s). 12 | */ 13 | [Event(name="change", type="flash.events.Event")] 14 | 15 | 16 | 17 | 18 | 94 | 95 | 96 | 105 | 106 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /src/com/codecatalyst/component/template/Group.mxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 43 | 44 | 45 | 49 | 50 | -------------------------------------------------------------------------------- /src/com/codecatalyst/component/template/RadioGroup.mxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | [DefaultProperty("itemRenderer")] 9 | 10 | /** 11 | * Dispatched when the user changes the selected item. 12 | */ 13 | [Event(name="change", type="flash.events.Event")] 14 | 15 | 16 | 17 | 18 | 94 | 95 | 96 | 104 | 105 | 109 | 110 | -------------------------------------------------------------------------------- /src/com/codecatalyst/component/text/Label.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.text 24 | { 25 | import mx.controls.Label; 26 | import mx.core.UITextField; 27 | 28 | /** 29 | * Specifies whether links in htmlText are underlined. 30 | * Possible values are "none", and "underline". 31 | * 32 | * @default "none" 33 | */ 34 | [Style(name="linkDecoration", type="String", enumeration="none,underline", inherit="yes")] 35 | 36 | /** 37 | * Color to use for links in htmlText. 38 | */ 39 | [Style(name="linkColor", type="uint", format="Color", inherit="yes")] 40 | 41 | /** 42 | * Specifies whether links in htmlText are underlined when hovered over. 43 | * Possible values are "none", and "underline". 44 | * 45 | * @default "none" 46 | */ 47 | [Style(name="hoverLinkDecoration", type="String", enumeration="none,underline", inherit="yes")] 48 | 49 | /** 50 | * Color to use for links in htmlText when hovered over. 51 | */ 52 | [Style(name="hoverLinkColor", type="uint", format="Color", inherit="yes")] 53 | 54 | /** 55 | * Specifies whether links in htmlText are underlined when active 56 | * Possible values are "none", and "underline". 57 | * 58 | * @default "none" 59 | */ 60 | [Style(name="activeLinkDecoration", type="String", enumeration="none,underline", inherit="yes")] 61 | 62 | /** 63 | * Color to use for links in htmlText when active. 64 | */ 65 | [Style(name="activeLinkColor", type="uint", format="Color", inherit="yes")] 66 | 67 | /** 68 | * Extends the standard Flex 3 Halo Label component to support new styles for specifying 69 | * hyperlink color and decoration (including normal, active and hover states) for htmlText. 70 | * 71 | * @example CSS sample 72 | * 73 | * 74 | * .hoverLinkText { 75 | * linkDecoration: none; 76 | * linkColor: #336699; 77 | * hoverLinkDecoration: "underline"; 78 | * hoverLinkColor: #336699; 79 | * activeLinkDecoration: "underline"; 80 | * activeLinkColor: #0000FF; 81 | * } 82 | * 83 | * 84 | * @author John Yanarella 85 | */ 86 | public class Label extends mx.controls.Label 87 | { 88 | // ======================================== 89 | // Constructor 90 | // ======================================== 91 | 92 | /** 93 | * Constructor. 94 | */ 95 | public function Label() 96 | { 97 | super(); 98 | } 99 | 100 | // ======================================== 101 | // Protected methods 102 | // ======================================== 103 | 104 | /** 105 | * @inheritDoc 106 | */ 107 | override protected function createInFontContext( classObj:Class ):Object 108 | { 109 | // Replace requests for UITextField with LinkifyTextField. 110 | 111 | if ( classObj == mx.core.UITextField ) 112 | classObj = com.codecatalyst.component.text.UITextField; 113 | 114 | return super.createInFontContext( classObj ); 115 | } 116 | } 117 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/component/text/Text.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.component.text 24 | { 25 | import mx.controls.Text; 26 | import mx.core.UITextField; 27 | 28 | /** 29 | * Specifies whether links in htmlText are underlined. 30 | * Possible values are "none", and "underline". 31 | * 32 | * @default "none" 33 | */ 34 | [Style(name="linkDecoration", type="String", enumeration="none,underline", inherit="yes")] 35 | 36 | /** 37 | * Color to use for links in htmlText. 38 | */ 39 | [Style(name="linkColor", type="uint", format="Color", inherit="yes")] 40 | 41 | /** 42 | * Specifies whether links in htmlText are underlined when hovered over. 43 | * Possible values are "none", and "underline". 44 | * 45 | * @default "none" 46 | */ 47 | [Style(name="hoverLinkDecoration", type="String", enumeration="none,underline", inherit="yes")] 48 | 49 | /** 50 | * Color to use for links in htmlText when hovered over. 51 | */ 52 | [Style(name="hoverLinkColor", type="uint", format="Color", inherit="yes")] 53 | 54 | /** 55 | * Specifies whether links in htmlText are underlined when active 56 | * Possible values are "none", and "underline". 57 | * 58 | * @default "none" 59 | */ 60 | [Style(name="activeLinkDecoration", type="String", enumeration="none,underline", inherit="yes")] 61 | 62 | /** 63 | * Color to use for links in htmlText when active. 64 | */ 65 | [Style(name="activeLinkColor", type="uint", format="Color", inherit="yes")] 66 | 67 | /** 68 | * Extends the standard Flex 3 Halo Text component to support new styles for specifying 69 | * hyperlink color and decoration (including normal, active and hover states) for htmlText. 70 | * 71 | * @example CSS sample 72 | * 73 | * 74 | * .hoverLinkText { 75 | * linkDecoration: none; 76 | * linkColor: #336699; 77 | * hoverLinkDecoration: "underline"; 78 | * hoverLinkColor: #336699; 79 | * activeLinkDecoration: "underline"; 80 | * activeLinkColor: #0000FF; 81 | * } 82 | * 83 | * 84 | * @author John Yanarella 85 | */ 86 | public class Text extends mx.controls.Text 87 | { 88 | // ======================================== 89 | // Constructor 90 | // ======================================== 91 | 92 | /** 93 | * Constructor. 94 | */ 95 | public function Text() 96 | { 97 | super(); 98 | } 99 | 100 | // ======================================== 101 | // Protected methods 102 | // ======================================== 103 | 104 | /** 105 | * @inheritDoc 106 | */ 107 | override protected function createInFontContext( classObj:Class ):Object 108 | { 109 | // Replace requests for UITextField with LinkifyTextField. 110 | 111 | if ( classObj == mx.core.UITextField ) 112 | classObj = com.codecatalyst.component.text.UITextField; 113 | 114 | return super.createInFontContext( classObj ); 115 | } 116 | } 117 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/data/FrequencyBin.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.data 24 | { 25 | public class FrequencyBin 26 | { 27 | // ======================================== 28 | // Protected properties 29 | // ======================================== 30 | 31 | /** 32 | * Backing variable for range property. 33 | * 34 | * @see #range 35 | */ 36 | protected var _range:NumericRange; 37 | 38 | /** 39 | * Backing variable for frequency property. 40 | * 41 | * @see #frequency 42 | */ 43 | protected var _frequency:Number; 44 | 45 | /** 46 | * Backing variable for percentage property. 47 | * 48 | * @see #percentage 49 | */ 50 | protected var _percentage:Number; 51 | 52 | // ======================================== 53 | // Public properties 54 | // ======================================== 55 | 56 | [Bindable("maximumChanged")] 57 | /** 58 | * Sample range. 59 | */ 60 | public function get range():NumericRange 61 | { 62 | return _range; 63 | } 64 | 65 | [Bindable("frequencyChanged")] 66 | /** 67 | * Sample frequency for range. 68 | */ 69 | public function get frequency():Number 70 | { 71 | return _frequency; 72 | } 73 | 74 | /** 75 | * Sample frequency percentage. 76 | */ 77 | public function get percentage():Number 78 | { 79 | return _percentage; 80 | } 81 | 82 | // ======================================== 83 | // Constructor 84 | // ======================================== 85 | 86 | /** 87 | * Constructor. 88 | */ 89 | public function FrequencyBin( range:NumericRange, frequency:Number, percentage:Number ) 90 | { 91 | super(); 92 | 93 | _range = range; 94 | _frequency = frequency; 95 | _percentage = percentage; 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/data/Option.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.data 24 | { 25 | import flash.events.Event; 26 | import flash.events.EventDispatcher; 27 | 28 | public class Option extends EventDispatcher 29 | { 30 | // ======================================== 31 | // Protected properties 32 | // ======================================== 33 | 34 | /** 35 | * Backing variable for label property. 36 | * 37 | * @see #label 38 | */ 39 | protected var _label:String = null; 40 | 41 | /** 42 | * Backing variable for value property. 43 | * 44 | * @see #value 45 | */ 46 | protected var _value:* = null; 47 | 48 | // ======================================== 49 | // Public properties 50 | // ======================================== 51 | 52 | [Bindable("labelChanged")] 53 | /** 54 | * Display label. 55 | */ 56 | public function get label():String 57 | { 58 | return _label; 59 | } 60 | 61 | [Bindable("valueChanged")] 62 | /** 63 | * Associated value. 64 | */ 65 | public function get value():* 66 | { 67 | return _value; 68 | } 69 | 70 | // ======================================== 71 | // Constructor 72 | // ======================================== 73 | 74 | /** 75 | * Constructor. 76 | */ 77 | public function Option( label:String, value:* ) 78 | { 79 | super(); 80 | 81 | _label = label; 82 | _value = value; 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/data/Property.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2009 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.data 24 | { 25 | import com.codecatalyst.util.PropertyUtil; 26 | 27 | public class Property 28 | { 29 | // ======================================== 30 | // Protected properties 31 | // ======================================== 32 | 33 | /** 34 | * Backing variable for path property. 35 | */ 36 | protected var _path:String; 37 | 38 | // ======================================== 39 | // Public properties 40 | // ======================================== 41 | 42 | /** 43 | * Returns the path for this property, using 'dot notation' (ex. 'a.b.c'). 44 | */ 45 | public function get path():String 46 | { 47 | return _path; 48 | } 49 | 50 | // ======================================== 51 | // Constructor 52 | // ======================================== 53 | 54 | /** 55 | * Constructor 56 | */ 57 | public function Property( path:String, parent:Property = null ) 58 | { 59 | _path = ( parent != null ) ? parent.path + "." + path : path; 60 | } 61 | 62 | // ======================================== 63 | // Public methods 64 | // ======================================== 65 | 66 | /** 67 | * Gets the value for a property of this type for a given object instance. 68 | */ 69 | public function getValue( object:Object ):* 70 | { 71 | return PropertyUtil.getObjectPropertyValue( object, path ); 72 | } 73 | 74 | /** 75 | * Sets the value for a property of this type for a given object instance. 76 | */ 77 | public function setValue( object:Object, value:* ):void 78 | { 79 | object[ path ] = value; 80 | } 81 | 82 | /** 83 | * Returns a Boolean indicating whether the specified object instance has this property. 84 | */ 85 | public function exists( object:Object ):Boolean 86 | { 87 | return PropertyUtil.hasProperty( object, path ); 88 | } 89 | 90 | /** 91 | * @inheritDoc 92 | */ 93 | public function toString():String 94 | { 95 | return path; 96 | } 97 | } 98 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/data/SampleSet.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.data 24 | { 25 | import com.codecatalyst.util.ArrayUtil; 26 | import com.codecatalyst.util.DateUtil; 27 | import com.codecatalyst.util.IterableUtil; 28 | 29 | public class SampleSet extends TemporalData 30 | { 31 | // ======================================== 32 | // Protected properties 33 | // ======================================== 34 | 35 | /** 36 | * Backing variable for samplingInterval property. 37 | * 38 | * @see #samplingInterval 39 | */ 40 | protected var _samplingInterval:TimeInterval = null; 41 | 42 | // ======================================== 43 | // Public properties 44 | // ======================================== 45 | 46 | /** 47 | * Time interval between samples in this sample set, in milliseconds. 48 | */ 49 | public function get samplingInterval():TimeInterval 50 | { 51 | return _samplingInterval; 52 | } 53 | 54 | // ======================================== 55 | // Constructor 56 | // ======================================== 57 | 58 | /** 59 | * Constructor. 60 | */ 61 | public function SampleSet( samples:Array, samplingInterval:TimeInterval, dateFieldName:String = "date", isSorted:Boolean = false ) 62 | { 63 | super( samples, dateFieldName, isSorted ); 64 | 65 | _samplingInterval = samplingInterval.clone(); 66 | } 67 | 68 | // ======================================== 69 | // Public methods 70 | // ======================================== 71 | 72 | /** 73 | * Create a new SampleSet containing the subset of samples available for the specified date range. 74 | */ 75 | override public function createSubset( targetDateRange:DateRange ):TemporalData 76 | { 77 | return new SampleSet( createDataSubset( targetDateRange ), samplingInterval, dateFieldName, true ); 78 | } 79 | 80 | /** 81 | * Get the sample that occurs on the specified Date, or null if unavailable. 82 | */ 83 | public function getSampleDyDate( date:Date ):Object 84 | { 85 | return IterableUtil.getItemByIndex( getDataItemsByDate( date ), 0 ); 86 | } 87 | 88 | /** 89 | * Get the sample that occurs nearest to the specified Date. 90 | */ 91 | public function getNearestSampleByDate( date:Date ):Object 92 | { 93 | return IterableUtil.getItemByIndex( getNearestDataItemsByDate( date ), 0 ); 94 | } 95 | } 96 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/data/enumeration/AbstractEnumeration.as: -------------------------------------------------------------------------------- 1 | package com.codecatalyst.data.enumeration 2 | { 3 | [Bindable] 4 | /** 5 | * An abstract implementation of an enumerated type where each element has an immutable id property. 6 | */ 7 | public class AbstractEnumeration 8 | { 9 | // ======================================== 10 | // Public properties 11 | // ======================================== 12 | 13 | /** 14 | * Unique identifier. 15 | */ 16 | public function get id():* 17 | { 18 | return _id; 19 | } 20 | 21 | // ======================================== 22 | // Protected properties 23 | // ======================================== 24 | 25 | /** 26 | * Backing variable for id. 27 | */ 28 | protected var _id:* = null; 29 | 30 | // ======================================== 31 | // Constructor 32 | // ======================================== 33 | 34 | /** 35 | * Constructor. 36 | */ 37 | public function AbstractEnumeration( id:String ) 38 | { 39 | super(); 40 | 41 | _id = id; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/data/enumeration/AbstractLabeledEnumeration.as: -------------------------------------------------------------------------------- 1 | package com.codecatalyst.data.enumeration 2 | { 3 | [Bindable] 4 | /** 5 | * An abstract implementation of an enumerated type where each element has an immutable id and displayLabel property. 6 | */ 7 | public class AbstractLabeledEnumeration extends AbstractEnumeration 8 | { 9 | // ======================================== 10 | // Public properties 11 | // ======================================== 12 | 13 | /** 14 | * Display label. 15 | */ 16 | public function get displayLabel():String 17 | { 18 | return _displayLabel; 19 | } 20 | 21 | // ======================================== 22 | // Public properties 23 | // ======================================== 24 | 25 | /** 26 | * Backing variable for displayLabel. 27 | */ 28 | protected var _displayLabel:String = null; 29 | 30 | // ======================================== 31 | // Constructor 32 | // ======================================== 33 | 34 | /** 35 | * Constructor. 36 | */ 37 | public function AbstractLabeledEnumeration( id:String, displayLabel:String ) 38 | { 39 | super( id ); 40 | 41 | _displayLabel = displayLabel; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/data/enumeration/IEnumeration.as: -------------------------------------------------------------------------------- 1 | package com.codecatalyst.data.enumeration 2 | { 3 | import flash.utils.Dictionary; 4 | 5 | /** 6 | * Interface that describes an enumerated type. 7 | */ 8 | public interface IEnumeration 9 | { 10 | function get id():*; 11 | } 12 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/spark/AnimatedNumericLabel.mxml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 104 | 105 | 106 | 107 | 108 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /src/com/codecatalyst/util/AsyncTokenUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2009 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import mx.rpc.AsyncToken; 26 | import mx.rpc.IResponder; 27 | import mx.rpc.Responder; 28 | 29 | /** 30 | * AsyncTokenUtil 31 | * 32 | * @author John Yanarella 33 | */ 34 | public class AsyncTokenUtil 35 | { 36 | /** 37 | * Creates and returns a proxy AsyncToken based on the specified AsyncToken, adding an intercepting IResponder 38 | * to the original token based on the specified result and fault Functions. 39 | * 40 | * The result and fault Functions may optionally transform the result or fault data to be used when the proxy 41 | * AsyncToken notifies its responders by returning a transformed value. 42 | */ 43 | public static function intercept( token:AsyncToken, result:Function, fault:Function = null ):AsyncToken 44 | { 45 | // Create a proxy AsyncToken based on the original AsyncToken. 46 | var proxyToken:AsyncToken = new AsyncToken( token.message ); 47 | 48 | // Create and add an intercepting IResponder to the original AsyncToken. 49 | token.addResponder( 50 | 51 | new Responder( 52 | 53 | // Create a result handling function closure. 54 | function ( data:Object ):void 55 | { 56 | var resultData:Object = data; 57 | 58 | // Execute the specified result interceptor function. 59 | 60 | if ( result != null ) 61 | { 62 | var interceptorReturnValue:* = result( data ); 63 | 64 | if ( interceptorReturnValue != undefined ) 65 | resultData = interceptorReturnValue; 66 | } 67 | 68 | // Notify the proxy AsyncToken's responders. 69 | for each ( var responder:IResponder in proxyToken.responders ) 70 | { 71 | responder.result( resultData ); 72 | } 73 | }, 74 | 75 | // Create a fault handling function closure. 76 | function ( info:Object ):void 77 | { 78 | var faultInfo:Object = info; 79 | 80 | // Execute the specified fault interceptor function. 81 | if ( fault != null ) 82 | { 83 | var interceptorReturnValue:* = fault( info ); 84 | 85 | if ( interceptorReturnValue != undefined ) 86 | faultInfo = interceptorReturnValue; 87 | } 88 | 89 | // Notify the proxy AsyncToken's responders. 90 | for each ( var responder:IResponder in proxyToken.responders ) 91 | { 92 | responder.fault( faultInfo ); 93 | } 94 | } 95 | ) 96 | ); 97 | 98 | return proxyToken; 99 | } 100 | 101 | } 102 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/BitmapDataUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2009 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import flash.display.BitmapData; 26 | import flash.display.Graphics; 27 | import flash.filters.ColorMatrixFilter; 28 | import flash.geom.ColorTransform; 29 | import flash.geom.Matrix; 30 | import flash.geom.Point; 31 | import flash.geom.Rectangle; 32 | 33 | public class BitmapDataUtil 34 | { 35 | // ======================================== 36 | // Public methods 37 | // ======================================== 38 | 39 | /** 40 | * Convert the specified BitmapData to grayscale. 41 | */ 42 | public static function grayscale( bitmapData:BitmapData ):BitmapData 43 | { 44 | var rLum:Number = 0.3086; 45 | var gLum:Number = 0.6094; 46 | var bLum:Number = 0.082; 47 | 48 | var matrix:Array = 49 | [ 50 | rLum, gLum, bLum, 0, 0, 51 | rLum, gLum, bLum, 0, 0, 52 | rLum, gLum, bLum, 0, 0, 53 | 0, 0, 0, 1, 0 54 | ]; 55 |   56 | var bitmapBounds:Rectangle = new Rectangle( 0, 0, bitmapData.width, bitmapData.height ); 57 | var filter:ColorMatrixFilter = new ColorMatrixFilter( matrix ); 58 | 59 | bitmapData.applyFilter( bitmapData, bitmapBounds, new Point( 0, 0 ), filter ); 60 | 61 | return bitmapData; 62 | } 63 | 64 | /** 65 | * Tint the specified BitmapData with the specified color. 66 | */ 67 | public static function tint( bitmapData:BitmapData, color:uint ):BitmapData 68 | { 69 | var r:int = ( ( color >> 16 ) & 0xFF ); 70 | var g:int = ( ( color >> 8 ) & 0xFF ); 71 | var b:int = ( ( color ) & 0xFF ); 72 | 73 | var bitmapBounds:Rectangle = new Rectangle( 0, 0, bitmapData.width, bitmapData.height ); 74 | var colorTransform:ColorTransform = new ColorTransform( 1.0, 1.0, 1.0, 1.0, r, g, b ); 75 | 76 | bitmapData.colorTransform( bitmapBounds, colorTransform ); 77 | 78 | return bitmapData; 79 | } 80 | 81 | /** 82 | * Adjust the brightness of the specified BitmapData by the specified percentage. 83 | */ 84 | public static function brightness( bitmapData:BitmapData, percentage:Number ):BitmapData 85 | { 86 | percentage = Math.max( -1.0, Math.min( 1.0, percentage ) ) * 255; 87 | 88 | if ( percentage != 0 ) 89 | { 90 | var matrix:Array = 91 | [ 92 | 1, 0, 0, 0, percentage, 93 | 0, 1, 0, 0, percentage, 94 | 0, 0, 1, 0, percentage, 95 | 0, 0, 0, 1, 0 96 | ]; 97 |   98 | var bitmapBounds:Rectangle = new Rectangle( 0, 0, bitmapData.width, bitmapData.height ); 99 | var filter:ColorMatrixFilter = new ColorMatrixFilter( matrix ); 100 | 101 | bitmapData.applyFilter( bitmapData, bitmapBounds, new Point( 0, 0 ), filter ); 102 | } 103 | 104 | return bitmapData; 105 | } 106 | 107 | /** 108 | * Adjust the transparency of the specified BitmapData by the specified percentage. 109 | */ 110 | public static function transparency( bitmapData:BitmapData, percentage:Number ):BitmapData 111 | { 112 | percentage = Math.max( 0.0, Math.min( 1.0, percentage ) ); 113 | 114 | var matrix:Array = 115 | [ 116 | 1, 0, 0, 0, 0, 117 | 0, 1, 0, 0, 0, 118 | 0, 0, 1, 0, 0, 119 | 0, 0, 0, percentage, 0 120 | ]; 121 |   122 | var bitmapBounds:Rectangle = new Rectangle( 0, 0, bitmapData.width, bitmapData.height ); 123 | var filter:ColorMatrixFilter = new ColorMatrixFilter( matrix ); 124 | 125 | bitmapData.applyFilter( bitmapData, bitmapBounds, new Point( 0, 0 ), filter ); 126 | 127 | return bitmapData; 128 | } 129 | } 130 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/ClassUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2009 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import flash.utils.getDefinitionByName; 26 | import flash.utils.getQualifiedClassName; 27 | 28 | public class ClassUtil 29 | { 30 | // ======================================== 31 | // Public methods 32 | // ======================================== 33 | 34 | /** 35 | * Get the corresponding Class for the specified String or Object instance. 36 | */ 37 | public static function getClassFor( source:* ):Class 38 | { 39 | if ( source == null ) 40 | return null; 41 | 42 | if ( source as Class != null ) 43 | return source as Class; 44 | 45 | if ( source is String ) 46 | return getDefinitionByName( source as String ) as Class; 47 | 48 | return getDefinitionByName( getQualifiedClassName( source ) ) as Class; 49 | } 50 | 51 | /** 52 | * Create an instance of the specified Class, using the specified parameters (up to 10 parameters). 53 | */ 54 | public static function createInstance( generator:Class, parameters:Array ):Object 55 | { 56 | var newInstance:Object; 57 | 58 | if ( ( parameters == null ) || ( parameters.length == 0 ) ) 59 | { 60 | newInstance = new generator(); 61 | } 62 | else 63 | { 64 | // Workaround for AS3 limitations. 65 | 66 | switch (parameters.length) 67 | { 68 | case 1: newInstance = new generator(parameters[0]); break; 69 | case 2: newInstance = new generator(parameters[0], parameters[1]); break; 70 | case 3: newInstance = new generator(parameters[0], parameters[1], parameters[2]); break; 71 | case 4: newInstance = new generator(parameters[0], parameters[1], parameters[2], parameters[3]); break; 72 | case 5: newInstance = new generator(parameters[0], parameters[1], parameters[2], parameters[3], parameters[4]); break; 73 | case 6: newInstance = new generator(parameters[0], parameters[1], parameters[2], parameters[3], parameters[4], parameters[5]); break; 74 | case 7: newInstance = new generator(parameters[0], parameters[1], parameters[2], parameters[3], parameters[4], parameters[5], parameters[6]); break; 75 | case 8: newInstance = new generator(parameters[0], parameters[1], parameters[2], parameters[3], parameters[4], parameters[5], parameters[6], parameters[7]); break; 76 | case 9: newInstance = new generator(parameters[0], parameters[1], parameters[2], parameters[3], parameters[4], parameters[5], parameters[6], parameters[7], parameters[8]); break; 77 | case 10: newInstance = new generator(parameters[0], parameters[1], parameters[2], parameters[3], parameters[4], parameters[5], parameters[6], parameters[7], parameters[8], parameters[9]); break; 78 | } 79 | } 80 | 81 | return newInstance; 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/CollectionViewUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2009 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import mx.collections.ArrayCollection; 26 | import mx.collections.ICollectionView; 27 | import mx.collections.IList; 28 | import mx.collections.ListCollectionView; 29 | import mx.collections.XMLListCollection; 30 | import mx.core.mx_internal; 31 | 32 | use namespace mx_internal; 33 | 34 | public class CollectionViewUtil 35 | { 36 | // ======================================== 37 | // Public methods 38 | // ======================================== 39 | 40 | /** 41 | * Create a ICollectionView for the specified data provider object. 42 | */ 43 | public static function create( value:Object ):ICollectionView 44 | { 45 | var collectionView:ICollectionView = null; 46 | 47 | if ( value is Array ) 48 | { 49 | collectionView = new ArrayCollection( value as Array ); 50 | } 51 | else if ( value is ICollectionView ) 52 | { 53 | collectionView = ICollectionView( value ); 54 | } 55 | else if ( value is IList ) 56 | { 57 | collectionView = new ListCollectionView( IList( value ) ); 58 | } 59 | else if ( value is XMLList ) 60 | { 61 | collectionView = new XMLListCollection( value as XMLList ); 62 | } 63 | else if ( value is XML ) 64 | { 65 | var xl:XMLList = new XMLList(); 66 | xl += value; 67 | 68 | collectionView = new XMLListCollection( xl ); 69 | } 70 | else 71 | { 72 | var temp:Array = []; 73 | 74 | if ( value != null ) 75 | temp.push( value ); 76 | 77 | collectionView = new ArrayCollection( temp ); 78 | } 79 | 80 | return collectionView; 81 | } 82 | 83 | /** 84 | * Silently clear the filterFunction and reset the list to have all elements available 85 | * for a future filter scan. 86 | * 87 | * @param target 88 | * @param silent 89 | */ 90 | public static function reset( target : ListCollectionView, silent:Boolean=true) : ListCollectionView 91 | { 92 | if (target.filterFunction != null) { 93 | 94 | var origFlag : Boolean = target.mx_internal::dispatchResetEvent; 95 | 96 | target.filterFunction = null; 97 | 98 | try { 99 | if (silent == true) { 100 | 101 | target.mx_internal::dispatchResetEvent = false; 102 | target.mx_internal::reset(); 103 | 104 | } else { 105 | 106 | target.refresh(); 107 | 108 | } 109 | 110 | } finally { 111 | 112 | target.mx_internal::dispatchResetEvent = origFlag; 113 | } 114 | } 115 | 116 | return target; 117 | } 118 | 119 | /** 120 | * Since ListCollectionViews may have filters applied to the list 121 | * this method quickly gathers all non-filtered items into an array. 122 | * 123 | * @param list ListCollectionView 124 | * @return Array 125 | */ 126 | public static function toArray( list:ListCollectionView ) : Array 127 | { 128 | var results : Array = [ ]; 129 | 130 | if ( list != null) 131 | { 132 | for each (var it:* in list) 133 | { 134 | results.push(it); 135 | } 136 | } 137 | 138 | return results; 139 | } 140 | } 141 | 142 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/DelayedCall.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2006 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import flash.events.TimerEvent; 26 | import flash.utils.Dictionary; 27 | import flash.utils.Timer; 28 | 29 | public class DelayedCall 30 | { 31 | // ======================================== 32 | // Protected properties 33 | // ======================================== 34 | 35 | /** 36 | * Scheduled calls. 37 | */ 38 | protected static var scheduledCalls:Dictionary = new Dictionary(); 39 | 40 | /** 41 | * Function. 42 | */ 43 | protected var func:Function = null; 44 | 45 | /** 46 | * Function arguments. 47 | */ 48 | protected var args:Array = null; 49 | 50 | /** 51 | * Scope context for the function invocation 52 | */ 53 | protected var scope:Object = null; 54 | 55 | // ======================================== 56 | // Constructor 57 | // ======================================== 58 | 59 | /** 60 | * Constructor. 61 | */ 62 | public function DelayedCall() 63 | { 64 | super(); 65 | } 66 | 67 | // ======================================== 68 | // Public methods 69 | // ======================================== 70 | 71 | /** 72 | * Schedule a delayed function or method call. 73 | * 74 | * @param func The function or class method to call. 75 | * @param args The parameters to pass to the function / class method. 76 | * @param delay The time in milliseconds to delay before making the function / class method call. 77 | */ 78 | public static function schedule( func:Function, args:Array, delay:Number, scope:Object=null ):void 79 | { 80 | var call:DelayedCall = new DelayedCall(); 81 | 82 | call.initiate( func, args, delay, scope ); 83 | 84 | // Grab a reference so the call doesn't get prematurely garbage-collected 85 | 86 | scheduledCalls[ call ] = call; 87 | } 88 | 89 | // ======================================== 90 | // Protected methods 91 | // ======================================== 92 | 93 | /** 94 | * Release reference to a completed DelayedCall instance. 95 | */ 96 | protected static function release( call:DelayedCall ):void 97 | { 98 | // Release reference so that call can be garbage-collected 99 | 100 | delete scheduledCalls[ call ]; 101 | } 102 | 103 | /** 104 | * Initiate a delayed call. 105 | */ 106 | protected function initiate( func:Function, args:Array, delay:Number, scope:Object=null ):void 107 | { 108 | this.func = func; 109 | this.args = args || [ ]; 110 | this.scope= scope; 111 | 112 | // Create and start a timer 113 | 114 | var timer:Timer = new Timer( delay, 1 ); 115 | timer.addEventListener( TimerEvent.TIMER_COMPLETE, timerCompleteHandler ); 116 | 117 | timer.start(); 118 | } 119 | 120 | /** 121 | * Handle TimerEvent.TIMER_COMPLETE - execute the delayed call. 122 | */ 123 | protected function timerCompleteHandler( event:TimerEvent ):void 124 | { 125 | var timer:Timer = event.target as Timer; 126 | timer.removeEventListener( TimerEvent.TIMER_COMPLETE, timerCompleteHandler ); 127 | 128 | // Execute the delayed function call 129 | 130 | if ( func != null ) 131 | func.apply( scope, args ); 132 | 133 | release( this ); 134 | } 135 | } 136 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/DisplayObjectContainerUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import flash.display.DisplayObject; 26 | import flash.display.DisplayObjectContainer; 27 | 28 | public class DisplayObjectContainerUtil 29 | { 30 | 31 | // ======================================== 32 | // Public methods 33 | // ======================================== 34 | 35 | [ArrayElementType("flash.display.DisplayObject")] 36 | /** 37 | * Returns an Array of the specified DisplayObjectContainer's children. 38 | */ 39 | public static function children(container:DisplayObjectContainer):Array 40 | { 41 | var children:Array = new Array(); 42 | 43 | if (container != null) 44 | { 45 | var numChildren:int = container.numChildren; 46 | for (var childIndex:int = 0; childIndex < numChildren; childIndex++) 47 | { 48 | var child:DisplayObject = container.getChildAt(childIndex); 49 | 50 | children.push(child); 51 | } 52 | } 53 | 54 | return children; 55 | } 56 | 57 | 58 | public static function contains(container:DisplayObjectContainer, target:DisplayObject):Boolean 59 | { 60 | return (children(container).indexOf(target) > -1); 61 | } 62 | 63 | /** 64 | * Brings the specified DisplayObject forward in z-order within the specified DisplayObjectContainer. 65 | */ 66 | public static function bringForward(container:DisplayObjectContainer, displayObject:DisplayObject):void 67 | { 68 | var childIndex:int = container.getChildIndex(displayObject); 69 | var targetIndex:int = (childIndex < container.numChildren - 1) ? childIndex++ : childIndex; 70 | 71 | container.setChildIndex(displayObject, targetIndex); 72 | } 73 | 74 | /** 75 | * Brings the specified DisplayObject to the front in z-order within the specified DisplayObjectContainer. 76 | */ 77 | public static function bringToFront(container:DisplayObjectContainer, displayObject:DisplayObject):void 78 | { 79 | var lastIndex:int = container.numChildren - 1; 80 | 81 | container.setChildIndex(displayObject, lastIndex); 82 | } 83 | 84 | /** 85 | * Sends the specified DisplayObject backward in z-order within the specified DisplayObjectContainer. 86 | */ 87 | public static function sendBackward(container:DisplayObjectContainer, displayObject:DisplayObject):void 88 | { 89 | var childIndex:int = container.getChildIndex(displayObject); 90 | var targetIndex:int = (childIndex > 0) ? childIndex-- : childIndex; 91 | 92 | container.setChildIndex(displayObject, targetIndex); 93 | } 94 | 95 | /** 96 | * Sends the specified DisplayObject to the back in z-order within the specified DisplayObjectContainer. 97 | */ 98 | public static function sendToBack(container:DisplayObjectContainer, displayObject:DisplayObject):void 99 | { 100 | var firstIndex:int = 0; 101 | 102 | container.setChildIndex(displayObject, firstIndex); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/com/codecatalyst/util/EventDispatcherUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2009 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import flash.events.IEventDispatcher; 26 | 27 | public class EventDispatcherUtil 28 | { 29 | // ======================================== 30 | // Public methods 31 | // ======================================== 32 | 33 | /** 34 | * Applies the specified styles to the specified style client. 35 | */ 36 | public static function addEventListeners( eventDispatcher:IEventDispatcher, eventListeners:Object, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = true ):void 37 | { 38 | if ( eventDispatcher == null ) return; 39 | 40 | if ( eventListeners != null ) 41 | { 42 | for ( var eventType:String in eventListeners ) 43 | { 44 | eventDispatcher.addEventListener( eventType, eventListeners[ eventType ], useCapture, priority, useWeakReference ); 45 | } 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/FactoryPool.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import flash.utils.Dictionary; 26 | 27 | import mx.core.ClassFactory; 28 | import mx.core.IFactory; 29 | 30 | public class FactoryPool implements IObjectPool 31 | { 32 | // ======================================== 33 | // Protected properties 34 | // ======================================== 35 | 36 | /** 37 | * Factory. 38 | */ 39 | protected var factory:IFactory; 40 | 41 | /** 42 | * Maximum size (i.e. maximum # of pooled instances). 43 | */ 44 | protected var maximumSize:Number = NaN; 45 | 46 | /** 47 | * Index of instances created by this pool. 48 | */ 49 | protected var instanceIndex:Dictionary = new Dictionary(); 50 | 51 | /** 52 | * Pooled instance(s). 53 | */ 54 | protected var pooledInstances:Array = new Array(); 55 | 56 | /** 57 | * Index of pooled instance(s) - for fast lookup. 58 | */ 59 | protected var pooledInstanceIndex:Dictionary = new Dictionary(); 60 | 61 | /** 62 | * Indicates whether this pool is full. 63 | */ 64 | protected function get isFull():Boolean 65 | { 66 | return ( ! isNaN( maximumSize ) && pooledInstances.length >= maximumSize ); 67 | } 68 | 69 | // ======================================== 70 | // Constructor 71 | // ======================================== 72 | 73 | /** 74 | * Constructor. 75 | */ 76 | public function FactoryPool( factory:IFactory, maximumSize:Number = NaN ) 77 | { 78 | super(); 79 | 80 | this.factory = factory; 81 | this.maximumSize = maximumSize; 82 | } 83 | 84 | // ======================================== 85 | // Public methods 86 | // ======================================== 87 | 88 | /** 89 | * @inheritDoc 90 | */ 91 | public function acquireInstance():* 92 | { 93 | if ( pooledInstances.length > 0 ) 94 | { 95 | // Pop and return a pooled instance. 96 | 97 | var pooledInstance:* = pooledInstances.pop(); 98 | pooledInstanceIndex[ pooledInstance ] = null; 99 | 100 | return pooledInstance; 101 | } 102 | else 103 | { 104 | // Create and return a new instance. 105 | 106 | var instance:* = factory.newInstance(); 107 | instanceIndex[ instance ] = true; 108 | 109 | return instance; 110 | } 111 | } 112 | 113 | /** 114 | * @inheritDoc 115 | */ 116 | public function releaseInstance( instance:* ):void 117 | { 118 | // Check that the specified instance was created by this FactoryPool instance. 119 | 120 | if ( instanceIndex[ instance ] != null ) 121 | { 122 | // Check that the pool is not full. 123 | 124 | if ( ! isFull ) 125 | { 126 | // Check that the specified instance is not already in the pool. 127 | 128 | if ( ! pooledInstanceIndex[ instance ] ) 129 | { 130 | // Add the instance to the pool. 131 | 132 | pooledInstances.push( instance ); 133 | pooledInstanceIndex[ instance ] = instance; 134 | } 135 | } 136 | else 137 | { 138 | instanceIndex[ instance ] = null; 139 | } 140 | } 141 | } 142 | 143 | /** 144 | * @inheritDoc 145 | */ 146 | public function reset():void 147 | { 148 | instanceIndex = null; 149 | pooledInstances = new Array(); 150 | pooledInstanceIndex = null; 151 | } 152 | } 153 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/FormatUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | public class FormatUtil 26 | { 27 | /** 28 | * Format the specified value as a Number with an ordinal suffix (ex. 1st, 2nd, 3rd, etc. ). 29 | */ 30 | public static function formatNumberOrdinalSuffix( value:* ):String 31 | { 32 | // Only apply an ordinal suffix if the number is a whole number. 33 | 34 | if ( NumberUtil.isWholeNumber( value ) ) 35 | { 36 | var number:Number = Number( value ); 37 | 38 | // Numbers from 11 to 13 don't have st, nd, rd 39 | 40 | if ( (number % 100) > 10 && (number % 100) < 14 ) 41 | return number + "th"; 42 | 43 | switch ( number % 10 ) 44 | { 45 | case 1: 46 | return number + "st"; 47 | case 2: 48 | return number + "nd"; 49 | case 3: 50 | return number + "rd"; 51 | default: 52 | return number + "th"; 53 | } 54 | } 55 | 56 | // Return the unaltered original value. 57 | 58 | return value; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/GraphicsUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import flash.display.Graphics; 26 | 27 | import mx.graphics.IStroke; 28 | 29 | import qs.utils.GraphicsUtils; 30 | 31 | public class GraphicsUtil 32 | { 33 | // ======================================== 34 | // Public methods 35 | // ======================================== 36 | 37 | /** 38 | * Draw lines connecting the specified iterable set (Array, IList, etc.) of coordinates (Point, etc.) with the specified stroke and dash pattern (optional). 39 | */ 40 | public static function drawPolyLine( graphics:Graphics, coordinates:*, stroke:IStroke, pattern:Array = null ):void 41 | { 42 | if ( pattern != null ) 43 | { 44 | GraphicsUtils.drawDashedPolyLine( graphics, stroke, pattern, coordinates ); 45 | } 46 | else 47 | { 48 | if ( coordinates.length == 0 ) 49 | return; 50 | 51 | CONFIG::FLEX3 { 52 | stroke.apply( graphics ); 53 | } 54 | CONFIG::FLEX4 { 55 | stroke.apply( graphics, null, null ); 56 | } 57 | 58 | var coordinate:Object = coordinates[ 0 ]; 59 | graphics.moveTo( coordinate.x, coordinate.y ); 60 | for ( var coordinateIndex:int = 1; coordinateIndex < coordinates.length; coordinateIndex++ ) 61 | { 62 | coordinate = coordinates[ coordinateIndex ]; 63 | graphics.lineTo( coordinate.x, coordinate.y ); 64 | } 65 | } 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/IObjectPool.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | public interface IObjectPool 26 | { 27 | // ======================================== 28 | // Methods 29 | // ======================================== 30 | 31 | /** 32 | * Acquire an instance (either new, or from the pool). 33 | */ 34 | function acquireInstance():* 35 | 36 | /** 37 | * Release the specified instance back to the pool. 38 | */ 39 | function releaseInstance( instance:* ):void 40 | 41 | /** 42 | * Resets this object pool. 43 | * 44 | * NOTE: Items previously requested from this pool will no longer be releaseable to it. 45 | */ 46 | function reset():void 47 | } 48 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/ImageUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2009 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import flash.display.Bitmap; 26 | 27 | public class ImageUtil 28 | { 29 | // ======================================== 30 | // Public methods 31 | // ======================================== 32 | 33 | /** 34 | * Return the specified image source converted to grayscale. 35 | */ 36 | public static function grayscale( source:Object ):Bitmap 37 | { 38 | var bitmap:Bitmap = createBitmap( source ); 39 | 40 | BitmapDataUtil.grayscale( bitmap.bitmapData ); 41 | 42 | return bitmap; 43 | } 44 | 45 | /** 46 | * Return the specified image source tinted with the specified color. 47 | */ 48 | public static function tint( source:Object, color:uint ):Bitmap 49 | { 50 | var bitmap:Bitmap = createBitmap( source ); 51 | 52 | BitmapDataUtil.tint( bitmap.bitmapData, color ); 53 | 54 | return bitmap; 55 | } 56 | 57 | /** 58 | * Return the specified image source with its brightness adjusted by the specified percentage. 59 | */ 60 | public static function brightness( source:Object, percentage:Number ):Bitmap 61 | { 62 | var bitmap:Bitmap = createBitmap( source ); 63 | 64 | BitmapDataUtil.brightness( bitmap.bitmapData, percentage ); 65 | 66 | return bitmap; 67 | } 68 | 69 | /** 70 | * Return the specified image source with its brightness adjusted by the specified percentage. 71 | */ 72 | public static function transparency( source:Object, percentage:Number ):Bitmap 73 | { 74 | var bitmap:Bitmap = createBitmap( source ); 75 | 76 | BitmapDataUtil.transparency( bitmap.bitmapData, percentage ); 77 | 78 | return bitmap; 79 | } 80 | 81 | // ======================================== 82 | // Protected methods 83 | // ======================================== 84 | 85 | /** 86 | * Create a Bitmap instance from the specified source. 87 | */ 88 | protected static function createBitmap( source:Object ):Bitmap 89 | { 90 | if ( source is Class ) 91 | { 92 | return new source() as Bitmap; 93 | } 94 | else if ( source is Bitmap ) 95 | { 96 | return source as Bitmap; 97 | } 98 | else 99 | { 100 | throw new Error( "Unsuported source specified." ); 101 | } 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/LogicUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | public class LogicUtil 26 | { 27 | // ======================================== 28 | // Public methods 29 | // ======================================== 30 | 31 | /** 32 | * Useful for Boolean operations in MXML tags. 33 | */ 34 | public static function and( ... args ):Boolean 35 | { 36 | var result:Boolean = true; 37 | 38 | for each ( var arg:* in args ) 39 | { 40 | result &&= arg; 41 | } 42 | 43 | return result; 44 | } 45 | 46 | /** 47 | * Useful for Boolean operations in MXML tags. 48 | */ 49 | public static function or( ... args ):Boolean 50 | { 51 | var result:Boolean = false; 52 | 53 | for each ( var arg:* in args ) 54 | { 55 | result ||= arg; 56 | } 57 | 58 | return result; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/MetadataUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | public class MetadataUtil 26 | { 27 | // ======================================== 28 | // Public methods 29 | // ======================================== 30 | 31 | /** 32 | * Get the specified attribute value for the specified metadata XML. 33 | */ 34 | public static function getMetadataAttribute( metadata:XML, attributeName:String, allowDefault:Boolean = false ):String 35 | { 36 | var value:String = metadata.arg.(@key == attributeName).@value; 37 | 38 | if ( value.length > 0 ) 39 | { 40 | return value; 41 | } 42 | else if ( allowDefault ) 43 | { 44 | return getMetadataAttribute( metadata, '' ); 45 | } 46 | else 47 | { 48 | return ""; 49 | } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/MouseUtil.as: -------------------------------------------------------------------------------- 1 | package com.codecatalyst.util 2 | { 3 | import flash.display.DisplayObject; 4 | 5 | public class MouseUtil 6 | { 7 | /** 8 | * @private 9 | * Returns true if the mouse is over the specified target. 10 | * 11 | * from ToolTipManagerImpl 12 | */ 13 | public static function mouseIsOver(target:DisplayObject):Boolean 14 | { 15 | if (!target || !target.stage) 16 | return false; 17 | 18 | //SDK:13465 - If we pass through the above if block, then 19 | //we have a target component and its been added to the 20 | //display list. If the mouse coordinates are (0,0), there 21 | //is a chance the component has not been positioned yet 22 | //and we'll end up mistakenly showing tooltips since the 23 | //target hitTest will return true. 24 | if ((target.stage.mouseX == 0) && (target.stage.mouseY == 0)) 25 | return false; 26 | 27 | return target.hitTestPoint(target.stage.mouseX, 28 | target.stage.mouseY, true); 29 | } 30 | 31 | } 32 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/NumberUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2010 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | 26 | public class NumberUtil 27 | { 28 | // ======================================== 29 | // Public methods 30 | // ======================================== 31 | 32 | /** 33 | * Comparator function for two Numbers. 34 | */ 35 | public static function compare(a:Number, b:Number):int 36 | { 37 | if (a < b) 38 | { 39 | return -1; 40 | } 41 | else if (b < a) 42 | { 43 | return 1; 44 | } 45 | else 46 | { 47 | return 0; 48 | } 49 | } 50 | 51 | /** 52 | * Returns a Boolean indicating whether the specified value is a whole number (ex. 1, 2, 3, etc.). 53 | */ 54 | public static function isWholeNumber(value:*):Boolean 55 | { 56 | var number:Number = Number(value); 57 | 58 | return (Math.floor(Math.abs(number)) == value); 59 | } 60 | 61 | /** 62 | * Returns the first parameter if it is a valid Number, otherwise returns the second parameter. 63 | */ 64 | public static function sanitizeNumber(value:*, otherwise:Number):Number 65 | { 66 | var number:Number = Number(value); 67 | 68 | return ((value == null) || isNaN(number)) ? otherwise : number; 69 | } 70 | 71 | public static function inRange(value:*, min:Number, max:Number):Boolean 72 | { 73 | var number:Number = Number(value); 74 | return ((value == null) || isNaN(number)) ? false : ((value >= min) && (value < max)); 75 | 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/com/codecatalyst/util/RandomUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2009 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | public class RandomUtil 26 | { 27 | // ======================================== 28 | // Public Methods 29 | // ======================================== 30 | 31 | /** 32 | * Returns a random number between the two numbers specified. 33 | * 34 | * NOTE: The difference between 'a' and 'b' must be less than or equal to Math.MAX_VALUE. 35 | */ 36 | public static function between( a:Number, b:Number ):Number 37 | { 38 | return ( a + ( Math.random() * ( b - a ) ) ); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/RectangleUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2008 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import flash.geom.Point; 26 | import flash.geom.Rectangle; 27 | 28 | public class RectangleUtil 29 | { 30 | // ======================================== 31 | // Public methods 32 | // ======================================== 33 | 34 | /** 35 | * Returns a Boolean value indicating whether the specified Rectangle is valid. 36 | */ 37 | public static function isValid( rectangle:Rectangle ):Boolean 38 | { 39 | if ( ( rectangle == null ) || isNaN( rectangle.width ) || isNaN( rectangle.height ) ) 40 | return false; 41 | 42 | return true; 43 | } 44 | 45 | /** 46 | * Returns a new normalized Rectangle based on the specified Rectangle. 47 | * 48 | * Any Rectangle with negative width or height becomes a Rectangle with positive width or height that extends to the upper-left of the original Rectangle. 49 | */ 50 | public static function normalize( rectangle:Rectangle ):Rectangle 51 | { 52 | var normalizedRectangle:Rectangle = rectangle.clone(); 53 | 54 | if ( normalizedRectangle.width < 0 ) 55 | { 56 | normalizedRectangle.x = normalizedRectangle.x + normalizedRectangle.width; 57 | normalizedRectangle.width = normalizedRectangle.width * -1; 58 | } 59 | 60 | if ( normalizedRectangle.height < 0 ) 61 | { 62 | normalizedRectangle.y = normalizedRectangle.y + normalizedRectangle.height; 63 | normalizedRectangle.height = normalizedRectangle.height * -1; 64 | } 65 | 66 | return normalizedRectangle; 67 | } 68 | 69 | /** 70 | * Returns a new Rectangle translated by the specified x and y coordinates. 71 | */ 72 | public static function translate( rectangle:Rectangle, x:Number, y:Number ):Rectangle 73 | { 74 | var translatedRectangle:Rectangle = rectangle.clone(); 75 | 76 | translatedRectangle.offset( x, y ); 77 | 78 | return translatedRectangle; 79 | } 80 | 81 | /** 82 | * Returns the center Point of the specified Rectangle. 83 | */ 84 | public static function center( rectangle:Rectangle ):Point 85 | { 86 | return new Point( ( rectangle.left + rectangle.right ) / 2.0, ( rectangle.top + rectangle.bottom ) / 2.0 ); 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/RuntimeEvaluationUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import com.codecatalyst.data.Property; 26 | 27 | public class RuntimeEvaluationUtil 28 | { 29 | // ======================================== 30 | // Public methods 31 | // ======================================== 32 | 33 | /** 34 | * Evaluates the specified value against the specified object instance. 35 | * 36 | * If the specified value is a String, it is evaluated as a potential property path in 'dot notation' and the corresponding instance value is returned. 37 | * If the specified value is a Function, it is called with the object instance (or evaluated callback field) as a parameter and its result is returned. 38 | * Otherwise the value is returned unaltered. 39 | * 40 | * @param instance Target object instance. 41 | * @param value String - potentially specifying a property path in 'dot notation', Function callback or standalone value. 42 | * @param callbackField Optional field to evaluate and pass to the callback function. 43 | * 44 | * @return The evaluated value. 45 | */ 46 | public static function evaluate( instance:*, value:*, callbackField:String = null ):* 47 | { 48 | if ( value is String ) 49 | { 50 | var property:Property = new Property( value as String ); 51 | 52 | return property.exists( instance ) ? property.getValue( instance ) : value; 53 | } 54 | else if ( value is Function ) 55 | { 56 | var callback:Function = value as Function; 57 | 58 | if ( callbackField ) 59 | { 60 | var callbackProperty:Property = new Property( callbackField ); 61 | 62 | return callback( callbackProperty.getValue( instance ) ); 63 | } 64 | else 65 | { 66 | return callback( instance ); 67 | } 68 | } 69 | else 70 | { 71 | return value; 72 | } 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/SkinUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2008 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import flash.display.DisplayObject; 26 | 27 | import mx.core.IFlexDisplayObject; 28 | import mx.core.IInvalidating; 29 | import mx.core.IProgrammaticSkin; 30 | import mx.managers.ILayoutManagerClient; 31 | import mx.styles.ISimpleStyleClient; 32 | 33 | public class SkinUtil 34 | { 35 | // ======================================== 36 | // Public methods 37 | // ======================================== 38 | 39 | /** 40 | * Creates an instance of the specified skin class. 41 | */ 42 | public static function create( skinClass:Class, styleName:Object ):DisplayObject 43 | { 44 | if ( skinClass != null ) 45 | { 46 | var skin:DisplayObject = new skinClass() as DisplayObject; 47 | 48 | if ( skin is IInvalidating ) 49 | { 50 | ( skin as IInvalidating ).validateNow(); 51 | } 52 | else if ( skin is IProgrammaticSkin ) 53 | { 54 | ( skin as IProgrammaticSkin ).validateDisplayList(); 55 | } 56 | 57 | if ( skin is ISimpleStyleClient ) 58 | { 59 | ( skin as ISimpleStyleClient ).styleName = styleName; 60 | } 61 | 62 | return skin; 63 | } 64 | 65 | return null; 66 | } 67 | 68 | /** 69 | * Simulate layout by the LayoutManager for the specified skin instance. 70 | */ 71 | public static function layout( skin:DisplayObject, owner:DisplayObject ):void 72 | { 73 | if ( ( skin is ILayoutManagerClient ) && ( owner is ILayoutManagerClient ) ) 74 | { 75 | ( skin as ILayoutManagerClient ).nestLevel = ( owner as ILayoutManagerClient ).nestLevel + 1; 76 | ( skin as ILayoutManagerClient ).initialized = true; 77 | } 78 | } 79 | 80 | /** 81 | * Position the specified skin instance. 82 | */ 83 | public static function resize( skin:DisplayObject, width:Number, height:Number ):void 84 | { 85 | if ( skin is IFlexDisplayObject ) 86 | { 87 | ( skin as IFlexDisplayObject ).setActualSize( width, height ); 88 | } 89 | else 90 | { 91 | skin.width = width; 92 | skin.height = height; 93 | } 94 | } 95 | 96 | /** 97 | * Validate the specified skin instance immediately. 98 | */ 99 | public static function validate( skin:DisplayObject ):void 100 | { 101 | if ( skin is IInvalidating ) 102 | { 103 | ( skin as IInvalidating ).validateNow(); 104 | } 105 | else if ( skin is IProgrammaticSkin ) 106 | { 107 | ( skin as IProgrammaticSkin ).validateDisplayList(); 108 | } 109 | } 110 | } 111 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/StringInflectionUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2008 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import mx.utils.StringUtil; 26 | 27 | public class StringInflectionUtil 28 | { 29 | // ======================================== 30 | // Public methods 31 | // ======================================== 32 | 33 | /** 34 | * Returns either the singular or plural String based on count. 35 | * 36 | * @example 37 | * 38 | * n( "Snake on a plane.", "Snakes on a plane!", count ); 39 | * n( "There is {0} goose.", "There are {0} geese.", count ); 40 | * 41 | */ 42 | public static function n( singular:String, plural:String, count:int ):String 43 | { 44 | return ( count > 1 ) ? StringUtil.substitute( plural, count ) : StringUtil.substitute( singular, count ); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/StyleUtil.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2009 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util 24 | { 25 | import com.codecatalyst.util.PropertyUtil; 26 | 27 | import flash.geom.Point; 28 | 29 | import mx.core.IFlexModuleFactory; 30 | import mx.styles.CSSStyleDeclaration; 31 | import mx.styles.IStyleClient; 32 | import mx.styles.StyleManager; 33 | 34 | 35 | public class StyleUtil 36 | { 37 | // ======================================== 38 | // Public methods 39 | // ======================================== 40 | 41 | /** 42 | * Gets the CSSStyleDeclaration object that stores the rules for the specified CSS selector. 43 | * 44 | * Normalizes the changes between Flex 3.x and Flex 4.x - specify the full path to the component class for both. 45 | * 46 | * @see mx.styles.IStyleManager#getStyleDeclaration() 47 | * @see mx.styles.IStyleManager2#getStyleDeclaration() 48 | */ 49 | public static function getStyleDeclaration( style:String, module:IFlexModuleFactory = null ):CSSStyleDeclaration 50 | { 51 | var result : CSSStyleDeclaration = null; 52 | 53 | CONFIG::FLEX3 { 54 | var expression:RegExp = /^(.*)\.([^.]+)$/; 55 | var match:Object = expression.exec( style ); 56 | 57 | var className:String = ( match ) ? match[ 1 ] as String : style; 58 | 59 | result = StyleManager.getStyleDeclaration( className ); 60 | } 61 | CONFIG::FLEX4 { 62 | result = StyleManager.getStyleManager( module ).getStyleDeclaration( style ); 63 | } 64 | 65 | return result; 66 | } 67 | 68 | /** 69 | * Sets the CSSStyleDeclaration object that stores the rules for the specified CSS selector. 70 | * 71 | * @see mx.styles.IStyleManager#setStyleDeclaration() 72 | * @see mx.styles.IStyleManager2#setStyleDeclaration() 73 | */ 74 | public static function setStyleDeclaration( style:String, declaration:CSSStyleDeclaration, update:Boolean = false, module:IFlexModuleFactory = null ):void 75 | { 76 | CONFIG::FLEX3 { 77 | StyleManager.setStyleDeclaration( style, declaration, update ); 78 | } 79 | CONFIG::FLEX4 { 80 | StyleManager.getStyleManager( module ).setStyleDeclaration( style, declaration, update ); 81 | } 82 | } 83 | 84 | /** 85 | * Applies the specified styles to the specified style client. 86 | */ 87 | /** 88 | * Apply the specified style key / value pairs to the specified object instance. 89 | * 90 | * @param instance Target object instance. 91 | * @param properties Style key / value pairs. 92 | * @param evaluate Indicates whether to evaluate the values against the instance. 93 | */ 94 | public static function applyStyles( styleClient:IStyleClient, styles:Object, evaluate:Boolean = false, callbackField:String = null ):void 95 | { 96 | if ( styles == null ) return; 97 | 98 | if ( styleClient != null ) 99 | { 100 | for ( var key:String in styles ) 101 | { 102 | var value:* = styles[ key ]; 103 | 104 | if ( evaluate ) 105 | { 106 | value = RuntimeEvaluationUtil.evaluate( styleClient, value, callbackField ); 107 | } 108 | 109 | styleClient.setStyle( key, value ); 110 | } 111 | } 112 | } 113 | 114 | /** 115 | * Parses a style value into a Point. 116 | */ 117 | public static function parsePoint( value:Object ):Point 118 | { 119 | if ( value is Point ) 120 | return value as Point; 121 | 122 | // TODO: Verify. 123 | if ( ( value is Array ) && ( value.length == 2 ) ) 124 | return new Point( value[ 0 ], value[ 1 ] ); 125 | 126 | return null; 127 | } 128 | 129 | // TODO: 130 | // parseRectangle( value:Object ):Rectangle 131 | // parseFill( value:Object ):IFill 132 | // parseStroke( value:Object ):IStroke 133 | } 134 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/invalidation/InvalidationFlags.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util.invalidation 24 | { 25 | [ExcludeClass] 26 | public class InvalidationFlags 27 | { 28 | // ======================================== 29 | // Public constants 30 | // ======================================== 31 | 32 | /** 33 | * None. 34 | */ 35 | public static const NONE:uint = 0; 36 | 37 | /** 38 | * Display list. 39 | */ 40 | public static const DISPLAY_LIST:uint = 1; 41 | 42 | /** 43 | * Properties. 44 | */ 45 | public static const PROPERTIES:uint = 2; 46 | 47 | /** 48 | * Size. 49 | */ 50 | public static const SIZE:uint = 4; 51 | } 52 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/invalidation/mxml/InvalidationTracker.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util.invalidation.mxml 24 | { 25 | import com.codecatalyst.util.invalidation.InvalidationTracker; 26 | 27 | import flash.events.IEventDispatcher; 28 | 29 | import mx.core.IMXMLObject; 30 | 31 | /** 32 | * MXML implementation of InvalidationTracker. 33 | * 34 | * @see com.codecatalyst.util.invalidation.InvalidationTracker 35 | */ 36 | public class InvalidationTracker extends com.codecatalyst.util.invalidation.InvalidationTracker implements IMXMLObject 37 | { 38 | // ======================================== 39 | // Protected properties 40 | // ======================================== 41 | 42 | /** 43 | * Indicates whether this component has been initialized. 44 | */ 45 | protected var _initialized:Boolean = false; 46 | 47 | // ======================================== 48 | // Constructor 49 | // ======================================== 50 | 51 | /** 52 | * Constructor. 53 | */ 54 | public function InvalidationTracker() 55 | { 56 | super( null ); 57 | } 58 | 59 | // ======================================== 60 | // Public methods 61 | // ======================================== 62 | 63 | /** 64 | * @inheritDoc 65 | */ 66 | public function initialized( document:Object, id:String ):void 67 | { 68 | source = document as IEventDispatcher; 69 | 70 | _initialized = true; 71 | 72 | setup(); 73 | } 74 | 75 | // ======================================== 76 | // Protected methods 77 | // ======================================== 78 | 79 | /** 80 | * @inheritDoc 81 | */ 82 | override protected function setup():void 83 | { 84 | if ( _initialized ) 85 | super.setup(); 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/persistence/IKeyValueStore.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util.persistence 24 | { 25 | /** 26 | * Interface describing a key value store. 27 | * 28 | * @author John Yanarella 29 | */ 30 | public interface IKeyValueStore 31 | { 32 | // ======================================== 33 | // Methods 34 | // ======================================== 35 | 36 | /** 37 | * Get the value for the specified key. 38 | */ 39 | function getValue( key:String ):Object; 40 | 41 | /** 42 | * Set the value for the specified key. 43 | */ 44 | function setValue( key:String, value:Object ):void; 45 | } 46 | } -------------------------------------------------------------------------------- /src/com/codecatalyst/util/persistence/KeyValueStoreAdapter.as: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2011 CodeCatalyst, LLC - http://www.codecatalyst.com/ 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | //////////////////////////////////////////////////////////////////////////////// 22 | 23 | package com.codecatalyst.util.persistence 24 | { 25 | /** 26 | * Concrete implementation of IKeyValueStore that adapts any key value store's get value and set value functions. 27 | * 28 | * @author John Yanarella 29 | */ 30 | public class KeyValueStoreAdapter implements IKeyValueStore 31 | { 32 | // ======================================== 33 | // Public factory methods. 34 | // ======================================== 35 | 36 | /** 37 | * Creates a new KeyValueStoreAdapter, adapting the specified get value / set value callback functions. 38 | */ 39 | public static function adapt( getValueCallback:Function, setValueCallback:Function ):KeyValueStoreAdapter 40 | { 41 | return new KeyValueStoreAdapter( getValueCallback, setValueCallback ); 42 | } 43 | 44 | // ======================================== 45 | // Public properties 46 | // ======================================== 47 | 48 | [Bindable] 49 | /** 50 | * Key value getter callback function. 51 | */ 52 | public var getValueCallback:Function = null; 53 | 54 | [Bindable] 55 | /** 56 | * Key value setter callback function. 57 | */ 58 | public var setValueCallback:Function = null; 59 | 60 | // ======================================== 61 | // Constructor 62 | // ======================================== 63 | 64 | /** 65 | * Constructor. 66 | */ 67 | public function KeyValueStoreAdapter( getValueCallback:Function = null, setValueCallback:Function = null ) 68 | { 69 | super(); 70 | 71 | this.getValueCallback = getValueCallback; 72 | this.setValueCallback = setValueCallback; 73 | } 74 | 75 | // ======================================== 76 | // Public methods. 77 | // ======================================== 78 | 79 | /** 80 | * @inheritDoc 81 | */ 82 | public function getValue( key:String ):Object 83 | { 84 | return getValueCallback( key ); 85 | } 86 | 87 | /** 88 | * @inheritDoc 89 | */ 90 | public function setValue( key:String, value:Object ):void 91 | { 92 | setValueCallback( key, value ); 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /src/design.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 17 | 18 | 19 | 20 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/qs/charts/DashedAreaRenderer.as: -------------------------------------------------------------------------------- 1 | package qs.charts 2 | { 3 | import mx.charts.renderers.AreaRenderer; 4 | import mx.graphics.IStroke; 5 | 6 | import qs.utils.GraphicsUtils; 7 | 8 | public class DashedAreaRenderer extends AreaRenderer 9 | { 10 | /** 11 | * Backing variable for pattern property. 12 | * 13 | * @see #pattern 14 | */ 15 | protected var _pattern:Array = [ 15 ]; 16 | 17 | /** 18 | * Constructor. 19 | */ 20 | public function DashedAreaRenderer() 21 | { 22 | super(); 23 | } 24 | 25 | /** 26 | * Dash pattern. 27 | */ 28 | public function set pattern( value:Array ):void 29 | { 30 | _pattern = value; 31 | 32 | invalidateDisplayList(); 33 | } 34 | public function get pattern():Array 35 | { 36 | return _pattern; 37 | } 38 | 39 | /** 40 | * @inheritDoc 41 | */ 42 | override public function getStyle( styleProp:String ):* 43 | { 44 | if ( styleProp == "areaStroke" ) 45 | return null; 46 | 47 | return super.getStyle( styleProp ); 48 | } 49 | 50 | /** 51 | * @inheritDoc 52 | */ 53 | override protected function updateDisplayList( unscaledWidth:Number, unscaledHeight:Number ):void 54 | { 55 | super.updateDisplayList( unscaledWidth, unscaledHeight ); 56 | 57 | var stroke:IStroke = super.getStyle( "areaStroke" ); 58 | 59 | var boundary:Array = data.filteredCache; 60 | if (boundary.length == 0) 61 | return; 62 | 63 | GraphicsUtils.drawDashedPolyLine( graphics, stroke, pattern, boundary ); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /src/qs/charts/DashedLineRenderer.as: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2006 Adobe Systems Incorporated 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | package qs.charts 26 | { 27 | import mx.core.IDataRenderer; 28 | import mx.graphics.IStroke; 29 | import mx.skins.ProgrammaticSkin; 30 | import mx.charts.series.items.LineSeriesSegment; 31 | 32 | import qs.utils.GraphicsUtils; 33 | 34 | public class DashedLineRenderer extends ProgrammaticSkin implements IDataRenderer 35 | { 36 | public function DashedLineRenderer() 37 | { 38 | super(); 39 | } 40 | 41 | private var _lineSegment:LineSeriesSegment; 42 | private var _pattern:Array = [15]; 43 | 44 | public function set pattern(value:Array):void 45 | { 46 | _pattern = value; 47 | invalidateDisplayList(); 48 | } 49 | public function get pattern():Array 50 | { 51 | return _pattern; 52 | } 53 | 54 | public function get data():Object 55 | { 56 | return _lineSegment; 57 | } 58 | 59 | public function set data(value:Object):void 60 | { 61 | _lineSegment = LineSeriesSegment(value); 62 | invalidateDisplayList(); 63 | } 64 | 65 | override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void 66 | { 67 | super.updateDisplayList(unscaledWidth, unscaledHeight); 68 | 69 | var stroke:IStroke = getStyle("lineStroke"); 70 | 71 | graphics.clear(); 72 | GraphicsUtils.drawDashedPolyLine(graphics, stroke, _pattern, _lineSegment.items.slice(_lineSegment.start, _lineSegment.end+1)); 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /src/qs/utils/GraphicsUtils.as: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2006 Adobe Systems Incorporated 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | package qs.utils 26 | { 27 | 28 | import mx.graphics.IStroke; 29 | import flash.display.Graphics; 30 | 31 | public class GraphicsUtils 32 | { 33 | public static function _drawDashedLine(target:Graphics, stroke:IStroke, pattern:Array, drawingState:DashStruct, x0:Number, y0:Number, x1:Number, y1:Number):void 34 | { 35 | var dX:Number = x1 - x0; 36 | var dY:Number = y1 - y0; 37 | var len:Number = Math.sqrt(dX*dX + dY*dY); 38 | 39 | if (len == 0) 40 | return; 41 | 42 | dX /= len; 43 | dY /= len; 44 | var tMax:Number = len; 45 | 46 | var t:Number = -drawingState.offset; 47 | var bDrawing:Boolean = drawingState.drawing; 48 | var patternIndex:int = drawingState.patternIndex; 49 | var styleInited:Boolean = drawingState.styleInited; 50 | while (t < tMax) 51 | { 52 | t += pattern[patternIndex]; 53 | if (t < 0) 54 | { 55 | var x:int = 5; 56 | } 57 | if (t >= tMax) 58 | { 59 | drawingState.offset = pattern[patternIndex] - (t - tMax); 60 | drawingState.patternIndex = patternIndex; 61 | drawingState.drawing = bDrawing; 62 | drawingState.styleInited = true; 63 | t = tMax; 64 | } 65 | 66 | if (styleInited == false) 67 | { 68 | if (bDrawing) 69 | { 70 | CONFIG::FLEX3 { 71 | stroke.apply( target ); 72 | } 73 | CONFIG::FLEX4 { 74 | stroke.apply( target, null, null ); 75 | } 76 | } 77 | else 78 | target.lineStyle(0, 0, 0); 79 | } 80 | else 81 | { 82 | styleInited = false; 83 | } 84 | 85 | target.lineTo(x0 + t*dX, y0 + t*dY); 86 | 87 | bDrawing = !bDrawing; 88 | patternIndex = (patternIndex + 1) % pattern.length; 89 | } 90 | } 91 | 92 | public static function drawDashedLine(target:Graphics, stroke:IStroke, pattern:Array, x0:Number, y0:Number, x1:Number, y1:Number):void 93 | { 94 | target.moveTo(x0, y0); 95 | var struct:DashStruct = new DashStruct(); 96 | _drawDashedLine(target, stroke, pattern, struct, x0, y0, x1, y1); 97 | } 98 | 99 | public static function drawDashedPolyLine(target:Graphics, stroke:IStroke, pattern:Array, points:Array):void 100 | { 101 | if (points.length == 0) 102 | return; 103 | 104 | var prev:Object = points[0]; 105 | 106 | var struct:DashStruct = new DashStruct(); 107 | target.moveTo(prev.x,prev.y); 108 | for (var i:int = 1; i < points.length; i++) 109 | { 110 | var current:Object = points[i]; 111 | _drawDashedLine(target, stroke, pattern, struct, prev.x, prev.y, current.x, current.y); 112 | prev = current; 113 | } 114 | } 115 | } 116 | } 117 | 118 | class DashStruct 119 | { 120 | public function DashStruct() {} 121 | 122 | public function init():void 123 | { 124 | drawing = true; 125 | patternIndex = 0; 126 | offset = 0; 127 | } 128 | 129 | public var drawing:Boolean = true; 130 | public var patternIndex:int = 0; 131 | public var offset:Number = 0; 132 | public var styleInited:Boolean = false; 133 | } 134 | -------------------------------------------------------------------------------- /src/utils/display/bringToFront.as: -------------------------------------------------------------------------------- 1 | package utils.display 2 | { 3 | import flash.display.DisplayObject; 4 | 5 | import utils.number.clamp; 6 | 7 | /** 8 | * Brings the DisplayObject to the front of the display list. The back parameter can be used to pull the DisplayObject back a few levels from the front. 9 | * @param object the DisplayObject to reorder 10 | * @param back the number of levels from the front of the display list 11 | * @return the new index of the DisplayObject 12 | */ 13 | public function bringToFront(object:DisplayObject, back:uint = 0):int 14 | { 15 | if (!object.parent) return -1; 16 | 17 | // Is this a Spark Container (with completely screwed up layer management) !? 18 | 19 | var spark : Boolean = object.parent.hasOwnProperty("setElementIndex"); 20 | 21 | var invoke: Function = spark ? object.parent["setElementIndex"] : object.parent["setChildIndex"]; 22 | var total : int = spark ? object.parent["numElements"] : object.parent["numChildren"]; 23 | var index : int = total - (back + 1); 24 | 25 | index = clamp(index, 0, total - 1); 26 | invoke(object, index); 27 | 28 | return index; 29 | } 30 | } -------------------------------------------------------------------------------- /src/utils/number/clamp.as: -------------------------------------------------------------------------------- 1 | package utils.number 2 | { 3 | /** 4 | * Constrains a value to the defined numeric boundaries. 5 | * 6 | * @example 7 | * clamp(3, 2, 5); // this will give back 3 since it's within the range 8 | * clamp(20, 2, 5); // this will give back 5 since 5 is the upper boundary 9 | * clamp(-5, 2, 5); // this will give back 2 since 2 is the lower boundary 10 | * 11 | * 12 | * @author Mims Wright 13 | */ 14 | public function clamp(val:Number, min:Number, max:Number):Number 15 | { 16 | return Math.max(Math.min(val, max), min); 17 | } 18 | } --------------------------------------------------------------------------------