Packageardisia.layouts
Classpublic class PackedLayout
InheritancePackedLayout Inheritance spark.layouts.supportClasses.LayoutBase

Layout class that lays out visual elements randomly, radially, or via a distribution function. The overlap of elements is minimized for each layout mode.

View the technical documentation on the Ardisia Labs website for more information.



Public Properties
 PropertyDefined By
  layoutMode : String
Layout modes available.
PackedLayout
  layoutRects : Vector.<Rectangle>
Vector of all the layout rectangles for the layout elements.
PackedLayout
  noiseFactor : Number
A random noise to add to the normal distribution, from 0 to 1.
PackedLayout
  peak : Number
The location of the peak of the distribution function, from 0 to 1.
PackedLayout
  resolution : int
The maximum number of passes allowed to minimize renderer overlap.
PackedLayout
Public Methods
 MethodDefined By
  
PackedLayout
  
Call to refresh the positions of the layout elements.
PackedLayout
Protected Methods
 MethodDefined By
  
getNormalizedPosition(weight:Number):Number
Return the position along the distribution function.
PackedLayout
  
getOverlap(proposedX:Number, proposedY:Number, proposedWidth:Number, proposedHeight:Number, width:Number, height:Number):Number
Returns the maximum overlap (area) that the passed proposed layout has with the other elements
PackedLayout
  
getPosition(rect:Rectangle, width:Number, height:Number, normalizedWeight:Number):Rectangle
Returns a position within the bounding box based on the layoutMode.
PackedLayout
Property Detail
layoutModeproperty
layoutMode:String

Layout modes available.

Random will simply place elements at random with minimized overlap.

Radial will position the elements radially around the center with minimized overlap in a more uniform way than the "weightedRadial" mode.

The weighted modes will use a distribution function tending to the quadrant defined in the mode with minimized overlap. The weight of elements corresponds to their dimensions.

The default value is "random".


Implementation
    public function get layoutMode():String
    public function set layoutMode(value:String):void
layoutRectsproperty 
public var layoutRects:Vector.<Rectangle>

Vector of all the layout rectangles for the layout elements.

The x and y property of each Rectangle is the percentage of the total width and height respectively. The index of each Rectangle is the same as the index of the corresponding layout element on the display list.

noiseFactorproperty 
noiseFactor:Number

A random noise to add to the normal distribution, from 0 to 1.

The default value is 0.25.


Implementation
    public function get noiseFactor():Number
    public function set noiseFactor(value:Number):void
peakproperty 
peak:Number

The location of the peak of the distribution function, from 0 to 1.

The default value is 0.35.


Implementation
    public function get peak():Number
    public function set peak(value:Number):void
resolutionproperty 
resolution:int

The maximum number of passes allowed to minimize renderer overlap. Higher numbers will reduce potential renderer overlapping, but processing will take longer.

Each pass is pure arithmetic so each pass is very fast.

The default value is 100.


Implementation
    public function get resolution():int
    public function set resolution(value:int):void
Constructor Detail
PackedLayout()Constructor
public function PackedLayout()



Method Detail
getNormalizedPosition()method
protected function getNormalizedPosition(weight:Number):Number

Return the position along the distribution function.

Parameters

weight:Number — Number

Returns
Number — Number
getOverlap()method 
protected function getOverlap(proposedX:Number, proposedY:Number, proposedWidth:Number, proposedHeight:Number, width:Number, height:Number):Number

Returns the maximum overlap (area) that the passed proposed layout has with the other elements

Parameters

proposedX:Number — the x position to check overlap
 
proposedY:Number — the y position to check overlap
 
proposedWidth:Number — the element width to check overlap
 
proposedHeight:Number — the element height to check overlap
 
width:Number — the Number width of the bounding box
 
height:Number — the Number height of the bounding box

Returns
Number — Number of the overlap area
getPosition()method 
protected function getPosition(rect:Rectangle, width:Number, height:Number, normalizedWeight:Number):Rectangle

Returns a position within the bounding box based on the layoutMode. Overlap with other layout elements is minimized.

Parameters

rect:Rectangle — the Rectangle to position
 
width:Number — the Number width of the bounding box
 
height:Number — the Number height of the bounding box
 
normalizedWeight:Number (default = NaN) — the normalizedWeight

Returns
Rectangle — Rectangle (percentX, percentY, elementWidth, elementHeight)
refreshPositions()method 
public function refreshPositions():void

Call to refresh the positions of the layout elements.