first commit
This commit is contained in:
170
com/yahoo/astra/fl/charts/skins/CircleSkin.as
Executable file
170
com/yahoo/astra/fl/charts/skins/CircleSkin.as
Executable file
@ -0,0 +1,170 @@
|
||||
/*
|
||||
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
|
||||
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
|
||||
*/
|
||||
package com.yahoo.astra.fl.charts.skins
|
||||
{
|
||||
import fl.core.UIComponent;
|
||||
import flash.display.Sprite;
|
||||
|
||||
/**
|
||||
* A skin shaped like a circle with a single color.
|
||||
*
|
||||
* @author Josh Tynjala
|
||||
*/
|
||||
public class CircleSkin extends UIComponent implements IProgrammaticSkin
|
||||
{
|
||||
|
||||
//--------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function CircleSkin()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
// Properties
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for the fillColor property.
|
||||
*/
|
||||
private var _fillColor:uint = 0x000000;
|
||||
|
||||
/**
|
||||
* @copy com.yahoo.astra.fl.charts.skins.IProgrammaticSkin#fillColor
|
||||
*/
|
||||
public function get fillColor():uint
|
||||
{
|
||||
return this._fillColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
public function set fillColor(value:uint):void
|
||||
{
|
||||
if(this._fillColor != value)
|
||||
{
|
||||
this._fillColor = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for outline color
|
||||
*/
|
||||
private var _borderColor:uint;
|
||||
|
||||
/**
|
||||
* @copy com.yahoo.astra.fl.charts.skins.IProgrammaticSkin#borderColor
|
||||
*/
|
||||
public function get borderColor():uint
|
||||
{
|
||||
return _borderColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private (setter)
|
||||
*/
|
||||
public function set borderColor(value:uint):void
|
||||
{
|
||||
if(this._borderColor != value)
|
||||
{
|
||||
this._borderColor = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for the fill alpha.
|
||||
*/
|
||||
private var _fillAlpha:Number = 1;
|
||||
|
||||
/**
|
||||
* The alpha value of the fill.
|
||||
*/
|
||||
public function get fillAlpha():Number
|
||||
{
|
||||
return _fillAlpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private (setter)
|
||||
*/
|
||||
public function set fillAlpha(value:Number):void
|
||||
{
|
||||
if(this._fillAlpha != value)
|
||||
{
|
||||
this._fillAlpha = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for the border alpha.
|
||||
*/
|
||||
private var _borderAlpha:Number = 1;
|
||||
|
||||
/**
|
||||
* The alpha value of the border.
|
||||
*/
|
||||
public function get borderAlpha():Number
|
||||
{
|
||||
return _borderAlpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private (setter)
|
||||
*/
|
||||
public function set borderAlpha(value:Number):void
|
||||
{
|
||||
if(this._borderAlpha != value)
|
||||
{
|
||||
this._borderAlpha = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
// Protected Methods
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
override protected function draw():void
|
||||
{
|
||||
super.draw();
|
||||
|
||||
this.graphics.clear();
|
||||
if(this.width == 0 || this.height == 0 || isNaN(this.width) || isNaN(this.height))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(this.fillColor == this.borderColor)
|
||||
{
|
||||
this.graphics.lineStyle(0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.graphics.lineStyle(1, this.borderColor, this.borderAlpha);
|
||||
}
|
||||
this.graphics.beginFill(this.fillColor, this.fillAlpha);
|
||||
this.graphics.drawCircle((this.width / 2), (this.height / 2), Math.min(this.width, this.height) / 2);
|
||||
this.graphics.endFill();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
182
com/yahoo/astra/fl/charts/skins/DiamondSkin.as
Executable file
182
com/yahoo/astra/fl/charts/skins/DiamondSkin.as
Executable file
@ -0,0 +1,182 @@
|
||||
/*
|
||||
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
|
||||
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
|
||||
*/
|
||||
package com.yahoo.astra.fl.charts.skins
|
||||
{
|
||||
import fl.core.UIComponent;
|
||||
|
||||
/**
|
||||
* A skin shaped like a diamond with a single color.
|
||||
*
|
||||
* @author Josh Tynjala
|
||||
*/
|
||||
public class DiamondSkin extends UIComponent implements IProgrammaticSkin
|
||||
{
|
||||
|
||||
//--------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function DiamondSkin()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
// Properties
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for the fillColor property.
|
||||
*/
|
||||
private var _fillColor:uint = 0x000000;
|
||||
|
||||
/**
|
||||
* @copy com.yahoo.astra.fl.charts.skins.IProgrammaticSkin#fillColor
|
||||
*/
|
||||
public function get fillColor():uint
|
||||
{
|
||||
return this._fillColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
public function set fillColor(value:uint):void
|
||||
{
|
||||
if(this._fillColor != value)
|
||||
{
|
||||
this._fillColor = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for outline color
|
||||
*/
|
||||
private var _borderColor:uint;
|
||||
|
||||
/**
|
||||
* @copy com.yahoo.astra.fl.charts.skins.IProgrammaticSkin#borderColor
|
||||
*/
|
||||
public function get borderColor():uint
|
||||
{
|
||||
return _borderColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private (setter)
|
||||
*/
|
||||
public function set borderColor(value:uint):void
|
||||
{
|
||||
if(this._borderColor != value)
|
||||
{
|
||||
this._borderColor = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for the fill alpha.
|
||||
*/
|
||||
private var _fillAlpha:Number = 1;
|
||||
|
||||
/**
|
||||
* The alpha value of the fill.
|
||||
*/
|
||||
public function get fillAlpha():Number
|
||||
{
|
||||
return _fillAlpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private (setter)
|
||||
*/
|
||||
public function set fillAlpha(value:Number):void
|
||||
{
|
||||
if(this._fillAlpha != value)
|
||||
{
|
||||
this._fillAlpha = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for the border alpha.
|
||||
*/
|
||||
private var _borderAlpha:Number = 1;
|
||||
|
||||
/**
|
||||
* The alpha value of the border.
|
||||
*/
|
||||
public function get borderAlpha():Number
|
||||
{
|
||||
return _borderAlpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private (setter)
|
||||
*/
|
||||
public function set borderAlpha(value:Number):void
|
||||
{
|
||||
if(this._borderAlpha != value)
|
||||
{
|
||||
this._borderAlpha = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
// Protected Methods
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
override protected function draw():void
|
||||
{
|
||||
super.draw();
|
||||
|
||||
this.graphics.clear();
|
||||
if(this.width == 0 || this.height == 0 || isNaN(this.width) || isNaN(this.height))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.borderColor == this.fillColor)
|
||||
{
|
||||
this.graphics.lineStyle(0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.graphics.lineStyle(1, this.borderColor, this.borderAlpha);
|
||||
}
|
||||
|
||||
this.graphics.beginFill(this.fillColor, this.fillAlpha);
|
||||
|
||||
var w:Number = 5 * Math.min(this.width, this.height) / 4;
|
||||
var h:Number = w;
|
||||
|
||||
var startX:Number = (this.width - w) / 2;
|
||||
var startY:Number = (this.height - h) / 2;
|
||||
var endX:Number = startX + w;
|
||||
var endY:Number = startY + h;
|
||||
|
||||
this.graphics.moveTo(startX, this.height / 2);
|
||||
this.graphics.lineTo(this.width / 2, startY);
|
||||
this.graphics.lineTo(endX, this.height / 2);
|
||||
this.graphics.lineTo(this.width / 2, endY);
|
||||
this.graphics.lineTo(startX, this.height / 2);
|
||||
this.graphics.endFill();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
59
com/yahoo/astra/fl/charts/skins/IProgrammaticSkin.as
Executable file
59
com/yahoo/astra/fl/charts/skins/IProgrammaticSkin.as
Executable file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
|
||||
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
|
||||
*/
|
||||
package com.yahoo.astra.fl.charts.skins
|
||||
{
|
||||
/**
|
||||
* A type of skin that supports color customization.
|
||||
*
|
||||
* @author Josh Tynjala
|
||||
*/
|
||||
public interface IProgrammaticSkin
|
||||
{
|
||||
|
||||
//--------------------------------------
|
||||
// Properties
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* The color used to draw the skin.
|
||||
*/
|
||||
function get fillColor():uint;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function set fillColor(value:uint):void;
|
||||
|
||||
/**
|
||||
* The color used for the outline of the skin
|
||||
*/
|
||||
function get borderColor():uint;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function set borderColor(value:uint):void;
|
||||
|
||||
/**
|
||||
* The alpha value of the fill.
|
||||
*/
|
||||
function get fillAlpha():Number;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function set fillAlpha(value:Number):void;
|
||||
|
||||
/**
|
||||
* The alpha value of the border.
|
||||
*/
|
||||
function get borderAlpha():Number;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function set borderAlpha(value:Number):void;
|
||||
}
|
||||
}
|
||||
174
com/yahoo/astra/fl/charts/skins/RectangleSkin.as
Executable file
174
com/yahoo/astra/fl/charts/skins/RectangleSkin.as
Executable file
@ -0,0 +1,174 @@
|
||||
/*
|
||||
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
|
||||
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
|
||||
*/
|
||||
package com.yahoo.astra.fl.charts.skins
|
||||
{
|
||||
import fl.core.UIComponent;
|
||||
|
||||
/**
|
||||
* A skin shaped like a rectangle with a single color.
|
||||
*
|
||||
* @author Josh Tynjala
|
||||
*/
|
||||
public class RectangleSkin extends UIComponent implements IProgrammaticSkin
|
||||
{
|
||||
|
||||
//--------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function RectangleSkin()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
// Properties
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for the fillColor property.
|
||||
*/
|
||||
private var _fillColor:uint = 0x000000;
|
||||
|
||||
/**
|
||||
* @copy com.yahoo.astra.fl.charts.skins.IProgrammaticSkin#fillColor
|
||||
*/
|
||||
public function get fillColor():uint
|
||||
{
|
||||
return this._fillColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
public function set fillColor(value:uint):void
|
||||
{
|
||||
if(this._fillColor != value)
|
||||
{
|
||||
this._fillColor = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for outline color
|
||||
*/
|
||||
private var _borderColor:uint;
|
||||
|
||||
/**
|
||||
* @copy com.yahoo.astra.fl.charts.skins.IProgrammaticSkin#borderColor
|
||||
*/
|
||||
public function get borderColor():uint
|
||||
{
|
||||
return _borderColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private (setter)
|
||||
*/
|
||||
public function set borderColor(value:uint):void
|
||||
{
|
||||
if(this._borderColor != value)
|
||||
{
|
||||
this._borderColor = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for the fill alpha.
|
||||
*/
|
||||
private var _fillAlpha:Number = 1;
|
||||
|
||||
/**
|
||||
* The alpha value of the fill.
|
||||
*/
|
||||
public function get fillAlpha():Number
|
||||
{
|
||||
return _fillAlpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private (setter)
|
||||
*/
|
||||
public function set fillAlpha(value:Number):void
|
||||
{
|
||||
if(this._fillAlpha != value)
|
||||
{
|
||||
this._fillAlpha = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for the border alpha.
|
||||
*/
|
||||
private var _borderAlpha:Number = 1;
|
||||
|
||||
/**
|
||||
* The alpha value of the border.
|
||||
*/
|
||||
public function get borderAlpha():Number
|
||||
{
|
||||
return _borderAlpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private (setter)
|
||||
*/
|
||||
public function set borderAlpha(value:Number):void
|
||||
{
|
||||
if(this._borderAlpha != value)
|
||||
{
|
||||
this._borderAlpha = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
// Protected Methods
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
override protected function draw():void
|
||||
{
|
||||
super.draw();
|
||||
|
||||
//since the Blaze component architecture rounds the position,
|
||||
//we need to account for that to make sure the mark displays correctly.
|
||||
var xDiff:Number = this._x - Math.round(this._x);
|
||||
var yDiff:Number = this._y - Math.round(this._y);
|
||||
|
||||
this.graphics.clear();
|
||||
if(this.width == 0 || this.height == 0 || isNaN(this.width) || isNaN(this.height))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.borderColor == this.fillColor)
|
||||
{
|
||||
this.graphics.lineStyle(0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.graphics.lineStyle(1, this.borderColor, this.borderAlpha);
|
||||
}
|
||||
|
||||
this.graphics.beginFill(this.fillColor, this.fillAlpha);
|
||||
this.graphics.drawRect(xDiff, yDiff, this.width, this.height);
|
||||
this.graphics.endFill();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
175
com/yahoo/astra/fl/charts/skins/TriangleSkin.as
Executable file
175
com/yahoo/astra/fl/charts/skins/TriangleSkin.as
Executable file
@ -0,0 +1,175 @@
|
||||
/*
|
||||
Copyright (c) 2009 Yahoo! Inc. All rights reserved.
|
||||
The copyrights embodied in the content of this file are licensed under the BSD (revised) open source license
|
||||
*/
|
||||
package com.yahoo.astra.fl.charts.skins
|
||||
{
|
||||
import fl.core.UIComponent;
|
||||
|
||||
/**
|
||||
* A skin shaped like a triangle with a single color.
|
||||
*
|
||||
* @author Josh Tynjala
|
||||
*/
|
||||
public class TriangleSkin extends UIComponent implements IProgrammaticSkin
|
||||
{
|
||||
|
||||
//--------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function TriangleSkin()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
// Properties
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for the fillColor property.
|
||||
*/
|
||||
private var _fillColor:uint = 0x000000;
|
||||
|
||||
/**
|
||||
* @copy com.yahoo.astra.fl.charts.skins.IProgrammaticSkin#fillColor
|
||||
*/
|
||||
public function get fillColor():uint
|
||||
{
|
||||
return this._fillColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
public function set fillColor(value:uint):void
|
||||
{
|
||||
if(this._fillColor != value)
|
||||
{
|
||||
this._fillColor = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for outline color
|
||||
*/
|
||||
private var _borderColor:uint;
|
||||
|
||||
/**
|
||||
* @copy com.yahoo.astra.fl.charts.skins.IProgrammaticSkin#borderColor
|
||||
*/
|
||||
public function get borderColor():uint
|
||||
{
|
||||
return _borderColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private (setter)
|
||||
*/
|
||||
public function set borderColor(value:uint):void
|
||||
{
|
||||
if(this._borderColor != value)
|
||||
{
|
||||
this._borderColor = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for the fill alpha.
|
||||
*/
|
||||
private var _fillAlpha:Number = 1;
|
||||
|
||||
/**
|
||||
* The alpha value of the fill.
|
||||
*/
|
||||
public function get fillAlpha():Number
|
||||
{
|
||||
return _fillAlpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private (setter)
|
||||
*/
|
||||
public function set fillAlpha(value:Number):void
|
||||
{
|
||||
if(this._fillAlpha != value)
|
||||
{
|
||||
this._fillAlpha = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Storage for the border alpha.
|
||||
*/
|
||||
private var _borderAlpha:Number = 1;
|
||||
|
||||
/**
|
||||
* The alpha value of the border.
|
||||
*/
|
||||
public function get borderAlpha():Number
|
||||
{
|
||||
return _borderAlpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private (setter)
|
||||
*/
|
||||
public function set borderAlpha(value:Number):void
|
||||
{
|
||||
if(this._borderAlpha != value)
|
||||
{
|
||||
this._borderAlpha = value;
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
// Protected Methods
|
||||
//--------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
override protected function draw():void
|
||||
{
|
||||
super.draw();
|
||||
|
||||
this.graphics.clear();
|
||||
if(this.width == 0 || this.height == 0 || isNaN(this.width) || isNaN(this.height))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.borderColor == this.fillColor)
|
||||
{
|
||||
this.graphics.lineStyle(0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.graphics.lineStyle(1, this.borderColor, this.borderAlpha);
|
||||
}
|
||||
this.graphics.beginFill(this.fillColor, this.fillAlpha);
|
||||
|
||||
var w:Number = this.width * 1.25;
|
||||
var h:Number = w * Math.sqrt(3) / 2;
|
||||
|
||||
this.graphics.moveTo(w / 2, 0);
|
||||
this.graphics.lineTo(w, h);
|
||||
this.graphics.lineTo(0, h);
|
||||
this.graphics.lineTo(w / 2, 0);
|
||||
this.graphics.endFill();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user