randomlayout.as

来自「用于flash/flex的 as3的 2D图形图像图表的动态生成」· AS 代码 · 共 37 行

AS
37
字号
package flare.vis.operator.layout
{
	import flare.vis.data.Data;
	import flare.vis.data.DataSprite;
	
	import flash.geom.Rectangle;
	
	/**
	 * Layout that places nodes randomly within the layout bounds.
	 */
	public class RandomLayout extends Layout
	{
		/** The data group to layout. */
		public var group:String;
		
		/**
		 * Creates a new RandomLayout instance. 
		 * @param group the data group to layout
		 */
		public function RandomLayout(group:String=Data.NODES) {
			this.group = group;
		}
		
		/** @inheritDoc */
		protected override function layout():void
		{
			var r:Rectangle = layoutBounds;
			visualization.data.visit(function(d:DataSprite):void
			{
				var o:Object = _t.$(d);
				o.x = r.x + r.width * Math.random();
				o.y = r.y + r.height * Math.random();
			}, group);
		}
		
	} // end of class RandomLayout
}

⌨️ 快捷键说明

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