⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shapepalette.as

📁 用于flash/flex的 as3的 2D图形图像图表的动态生成
💻 AS
字号:
package flare.util.palette
{
	import flare.util.Shapes;
	
	/**
	 * Palette for shape values that maps integer indices to shape drawing
	 * functions.
	 * @see flare.vis.util.graphics.Shapes
	 */
	public class ShapePalette extends Palette
	{	
		/**
		 * Creates a new, empty ShapePalette.
		 */
		public function ShapePalette() {
			_values = new Array();
		}	
		
		/**
		 * Adds a shape to this ShapePalette.
		 * @param shape the name of the shape. This name should be registered
		 *  with a drawing function using the
		 *  <code>flare.vis.util.graphics.Shapes</code> class.
		 */
		public function addShape(shape:String):void
		{
			_values.push(shape);
		}
		
		/**
		 * Gets the shape at the given index into the palette.
		 * @param idx the index of the shape
		 * @return the name of the shape
		 */
		public function getShape(idx:uint):String
		{
			return _values[idx % _values.length];
		}
		
		/**
		 * Sets the shape at the given index into the palette.
		 * @param idx the index of the shape
		 * @param shape the name of the shape. This name should be registered
		 *  with a drawing function using the
		 *  <code>flare.vis.util.graphics.Shapes</code> class.
		 */
		public function setShape(idx:uint, shape:String):void
		{
			_values[idx] = shape;
		}
		
		/**
		 * Returns a default shape palette instance. The default palette
		 * consists of (in order): circle, square, cross, "x", diamond,
		 * down-triangle, up-triangle, left-triangle, and right-triangle
		 * shapes.
		 * @return the default shape palette
		 */
		public static function defaultPalette():ShapePalette
		{
			var p:ShapePalette = new ShapePalette();
			p.addShape(Shapes.CIRCLE);
			p.addShape(Shapes.SQUARE);
			p.addShape(Shapes.CROSS);
			p.addShape(Shapes.X);
			p.addShape(Shapes.DIAMOND);
			p.addShape(Shapes.TRIANGLE_DOWN);
			p.addShape(Shapes.TRIANGLE_UP);
			p.addShape(Shapes.TRIANGLE_LEFT);
			p.addShape(Shapes.TRIANGLE_RIGHT);
			return p;
		}
		
	} // end of class ShapePalette
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -