Packagetwaver
Classpublic final class Utils
InheritanceUtils Inheritance Object

This is a final, all-static utility class offers many static utility methods that used in TWaver Flex.



Public Properties
 PropertyDefined By
  isDeserializing : Boolean = false
[static] The flag indicated whether it is deserializing now.
Utils
  VERSION : String
[static] [read-only] Get current TWaver Flex version with a string.
Utils
Public Methods
 MethodDefined By
  
addImageLoadedListener(listener:Function, priority:int = 0):void
[static] Add a listener to monitor image loaded event.
Utils
  
animateBound(node:Node, bound:Rectangle, finishFunction:Function = null, ui:UIComponent = null):void
[static] Changes nodes bound animately.
Utils
  
animateCenterLocation(locations:Dictionary, finishFunction:Function = null, ui:UIComponent = null):void
[static] Changes nodes center location animately.
Utils
  
animateLocation(locations:Dictionary, finishFunction:Function = null, ui:UIComponent = null):void
[static] Changes nodes location animately.
Utils
  
animateMove(nodes:ICollection, xOffset:Number, yOffset:Number, finishFunction:Function = null, ui:UIComponent = null):void
[static] Moves nodes location with offset animately.
Utils
  
beginFill(g:Graphics, fillColor:Number, fillAlpha:Number = 1, x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0, gradient:String = null, gradientColor:Number = 0, gradientAlpha:Number = 1):void
[static] Fill a bound with specified parameters.
Utils
  
calculatePointAngleAlongLine(points:ICollection, segments:ICollection, isSource:Boolean = true, xOffset:Number = 0, yOffset:Number = 0):Array
[static] Calculate point and angle along path.
Utils
  
[static] Clear BitmapData Cache in different dyed color.
Utils
  
containsImage(name:String):Boolean
[static] Check whether contains a specified image name.
Utils
  
createMagnifierFilter(radiusX:int, radiusY:int, fisheye:Boolean, point:Point = null):DisplacementMapFilter
[static] Create magnifier filter.
Utils
  
dispatchImageLoadedEvent(name:String, imageAsset:IImageAsset):void
[static] Dispatch a image loaded event.
Utils
  
drawFromArrow(g:Graphics, points:ICollection, ui:ElementUI, segments:ICollection = null):void
[static] Draw from arrow.
Utils
  
drawImage(g:Graphics, name:String, x:Number, y:Number, w:Number, h:Number, color:* = null, stretch:String = uniform, shape:String = rectangle):void
[static] Draw image on graphics with specified parameters.
Utils
  
drawShape(g:Graphics, shape:String, x:Number, y:Number, width:Number, height:Number):void
[static] Draw image on graphics with specified parameters.
Utils
  
drawToArrow(g:Graphics, points:ICollection, ui:ElementUI, segments:ICollection = null):void
[static] Draw to arrow.
Utils
  
filterMovingElements(elements:ICollection, filter:Function = null):ICollection
[static] Filters out moving elements.
Utils
  
getClass(object:Object):Class
[static] Get specified object class type.
Utils
  
getImageAsset(name:String, errorWhenNull:Boolean = true):IImageAsset
[static] Get image resource by registered name.
Utils
  
getPropertyName(e:PropertyChangeEvent):String
[static] Digs out property name from the given property change event.
Utils
  
getQualifiedClassName(object:Object):String
[static] Get qualified class name of specified object.
Utils
  
[static] Get the subnetwork element of specified element displaying.
Utils
  
getSuperClass(clazz:Class):Class
[static] Get super class type.
Utils
  
isPermissionGIS():Boolean
[static]
Utils
  
moveElements(elements:ICollection, xoffset:Number, yoffset:Number, animate:Boolean = false, finishFunction:Function = null, ui:UIComponent = null):void
[static] Move elements with animate effect.
Utils
  
randomBoolean():Boolean
[static] Get random boolean value.
Utils
  
randomColor():Number
[static] Get a random color.
Utils
  
randomInt(n:int):int
[static] Get random int less than the specified int number.
Utils
  
[static] Get a random predefined alarm severity except the cleared severity.
Utils
  
randomRange(min:Number, max:Number):Number
[static] Get a random number between the specified number range.
Utils
  
[static] Get a random predefined alarm severity.
Utils
  
registerImageByBitmapData(name:String, bitmapData:BitmapData):void
[static] Register a bitmap image resource in TWaver Flex.
Utils
  
registerImageByClass(name:String, imageClass:Class, asComponent:Boolean = false, bounds:Rectangle = null, args:Array = null):void
[static] Register a resource (image, movie clip...) in TWaver Flex by resource class type.
Utils
  
registerImageByDisplayObject(name:String, displayObject:DisplayObject, bounds:Rectangle = null):void
[static] Register a resource (image, movie clip...) in TWaver Flex and embed it in specified display object.
Utils
  
registerImageByUrl(name:String, url:String):void
[static] Get image resource by url.
Utils
  
registerSmoothingImage(name:String, imageClass:Class, bounds:Rectangle = null, args:Array = null):void
[static] Register a resource (image, movie clip...) in TWaver Flex with scale-smoothing effect.
Utils
  
toDegrees(radian:Number):Number
[static] Change specified angle from radian to degree.
Utils
  
toHexString(object:Object):String
[static] Get a hex string format of specified number object.
Utils
  
toRadians(degree:Number):Number
[static] Change specified angle from degree to radian.
Utils
  
validateLicense(license:*):Boolean
[static] Validate TWaver Flex license.
Utils
Property Detail
isDeserializingproperty
public static var isDeserializing:Boolean = false

The flag indicated whether it is deserializing now.

VERSIONproperty 
VERSION:String  [read-only]

Get current TWaver Flex version with a string.


Implementation
    public static function get VERSION():String
Method Detail
addImageLoadedListener()method
public static function addImageLoadedListener(listener:Function, priority:int = 0):void

Add a listener to monitor image loaded event.

Parameters

listener:Function
 
priority:int (default = 0)

animateBound()method 
public static function animateBound(node:Node, bound:Rectangle, finishFunction:Function = null, ui:UIComponent = null):void

Changes nodes bound animately.

Parameters

node:Node — the node to be changed.
 
bound:Rectangle — the new bound.
 
finishFunction:Function (default = null) — a function will be called when movement finished.
 
ui:UIComponent (default = null) — UI component the animation based on.

animateCenterLocation()method 
public static function animateCenterLocation(locations:Dictionary, finishFunction:Function = null, ui:UIComponent = null):void

Changes nodes center location animately.

Parameters

locations:Dictionary — the Dictionary, key is node, value is new center location.
 
finishFunction:Function (default = null) — a function will be called when movement finished.
 
ui:UIComponent (default = null) — UI component the animation based on.

animateLocation()method 
public static function animateLocation(locations:Dictionary, finishFunction:Function = null, ui:UIComponent = null):void

Changes nodes location animately.

Parameters

locations:Dictionary — the Dictionary, key is node, value is new location.
 
finishFunction:Function (default = null) — a function will be called when movement finished.
 
ui:UIComponent (default = null) — UI component the animation based on.

animateMove()method 
public static function animateMove(nodes:ICollection, xOffset:Number, yOffset:Number, finishFunction:Function = null, ui:UIComponent = null):void

Moves nodes location with offset animately.

Parameters

nodes:ICollection — the nodes to be moved.
 
xOffset:Number — the x offset.
 
yOffset:Number — the y offset.
 
finishFunction:Function (default = null) — a function will be called when movement finished.
 
ui:UIComponent (default = null) — UI component the animation based on.

beginFill()method 
public static function beginFill(g:Graphics, fillColor:Number, fillAlpha:Number = 1, x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0, gradient:String = null, gradientColor:Number = 0, gradientAlpha:Number = 1):void

Fill a bound with specified parameters.

Parameters

g:Graphics — the graphics to fill on
 
fillColor:Number — fill color
 
fillAlpha:Number (default = 1) — alpha transparent value of the fill color
 
x:Number (default = 0) — x location of the fill bounds.
 
y:Number (default = 0) — y location of the fill bounds.
 
width:Number (default = 0) — width value of the fill bounds.
 
height:Number (default = 0) — height value of the fill bounds.
 
gradient:String (default = null) — fill gradient pattern.
 
gradientColor:Number (default = 0) — fill gradient color.
 
gradientAlpha:Number (default = 1) — fill gradent color alpha value.

calculatePointAngleAlongLine()method 
public static function calculatePointAngleAlongLine(points:ICollection, segments:ICollection, isSource:Boolean = true, xOffset:Number = 0, yOffset:Number = 0):Array

Calculate point and angle along path.

Parameters

points:ICollection — of the path.
 
segments:ICollection — of the path. Object inside this collection can be: Consts.SETMENT_MOVETO, Consts.SETMENT_LINETO, Consts.SETMENT_QUADTO.
 
isSource:Boolean (default = true) — true if starting from beginning.
 
xOffset:Number (default = 0) — x offset.
 
yOffset:Number (default = 0) — y offset.

Returns
Array — [point, angle]
clearBitmapDataCache()method 
public static function clearBitmapDataCache():void

Clear BitmapData Cache in different dyed color.

containsImage()method 
public static function containsImage(name:String):Boolean

Check whether contains a specified image name.

Parameters

name:String — the image name that need to be checked.

Returns
Boolean — true if contains, false otherwise.
createMagnifierFilter()method 
public static function createMagnifierFilter(radiusX:int, radiusY:int, fisheye:Boolean, point:Point = null):DisplacementMapFilter

Create magnifier filter.

Parameters

radiusX:int — The X radius of filter.
 
radiusY:int — The Y radius of filter.
 
fisheye:Boolean — true if fisheye, false if magnify.
 
point:Point (default = null) — A value that contains the offset of the upper-left corner of the target display object from the upper-left corner of the map image.

Returns
DisplacementMapFilter — DisplacementMapFilter
dispatchImageLoadedEvent()method 
public static function dispatchImageLoadedEvent(name:String, imageAsset:IImageAsset):void

Dispatch a image loaded event.

Parameters

name:String
 
imageAsset:IImageAsset

drawFromArrow()method 
public static function drawFromArrow(g:Graphics, points:ICollection, ui:ElementUI, segments:ICollection = null):void

Draw from arrow.

Parameters

g:Graphics
 
points:ICollection
 
ui:ElementUI
 
segments:ICollection (default = null)

drawImage()method 
public static function drawImage(g:Graphics, name:String, x:Number, y:Number, w:Number, h:Number, color:* = null, stretch:String = uniform, shape:String = rectangle):void

Draw image on graphics with specified parameters.

Parameters

g:Graphics — graphics the image to draw.
 
name:String — image resource register name.
 
x:Number — the x location of image
 
y:Number — the y location of image
 
w:Number — width of image to draw
 
h:Number — height of image to draw
 
color:* (default = null) — image render color.
 
stretch:String (default = uniform) — image stretch policy. It can be:
  • Consts.STRETCH_CENTER
  • Consts.STRETCH_UNIFORM
  • Consts.STRETCH_FILL
  • Consts.STRETCH_UNIFORM_TO_FILL
  • Consts.STRETCH_SOUTHWEST
  • Consts.STRETCH_SOUTHEAST
  • Consts.STRETCH_NORTHWEST
  • Consts.STRETCH_NORTHEAST
  • Consts.STRETCH_NORTH
  • Consts.STRETCH_SOUTH
  • Consts.STRETCH_WEST
  • Consts.STRETCH_EAST
  • Consts.STRETCH_CENTER_UNIFORM
  • Consts.STRETCH_SOUTHWEST_UNIFORM
  • Consts.STRETCH_SOUTHEAST_UNIFORM
  • Consts.STRETCH_NORTHWEST_UNIFORM
  • Consts.STRETCH_NORTHEAST_UNIFORM
  • Consts.STRETCH_NORTH_UNIFORM
  • Consts.STRETCH_SOUTH_UNIFORM
  • Consts.STRETCH_WEST_UNIFORM
  • Consts.STRETCH_EAST_UNIFORM
 
shape:String (default = rectangle) — a shape draw with this image. It can be:
  • Consts.SHAPE_RECTANGLE
  • Consts.SHAPE_OVAL
  • Consts.SHAPE_ROUNDRECT
  • Consts.SHAPE_STAR
  • Consts.SHAPE_TRIANGLE
  • Consts.SHAPE_CIRCLE
  • Consts.SHAPE_HEXAGON
  • Consts.SHAPE_PENTAGON
  • Consts.SHAPE_DIAMOND

drawShape()method 
public static function drawShape(g:Graphics, shape:String, x:Number, y:Number, width:Number, height:Number):void

Draw image on graphics with specified parameters.

Parameters

g:Graphics — the graphics this image draw on.
 
shape:String
 
x:Number — a shape draw with this image. It can be:
  • Consts.SHAPE_RECTANGLE
  • Consts.SHAPE_OVAL
  • Consts.SHAPE_ROUNDRECT
  • Consts.SHAPE_STAR
  • Consts.SHAPE_TRIANGLE
  • Consts.SHAPE_CIRCLE
  • Consts.SHAPE_HEXAGON
  • Consts.SHAPE_PENTAGON
  • Consts.SHAPE_DIAMOND
 
y:Number — image draw bound x location.
 
width:Number — image draw bound y location.
 
height:Number — image draw bound width.

drawToArrow()method 
public static function drawToArrow(g:Graphics, points:ICollection, ui:ElementUI, segments:ICollection = null):void

Draw to arrow.

Parameters

g:Graphics
 
points:ICollection
 
ui:ElementUI
 
segments:ICollection (default = null)

filterMovingElements()method 
public static function filterMovingElements(elements:ICollection, filter:Function = null):ICollection

Filters out moving elements. for example when two node host with each ohter, you just need to move one node.

Parameters

elements:ICollection — The element to be moved.
 
filter:Function (default = null) — The additional filter, default value is null.

Returns
ICollection — The elements that really need to be moved.
getClass()method 
public static function getClass(object:Object):Class

Get specified object class type.

Parameters

object:Object — the object to be checked.

Returns
Class — the class type of this object.
getImageAsset()method 
public static function getImageAsset(name:String, errorWhenNull:Boolean = true):IImageAsset

Get image resource by registered name.

Parameters

name:String — the image resource registered name
 
errorWhenNull:Boolean (default = true) — whether throw error if resource is null.

Returns
IImageAsset — registered image resource with the specified name.
getPropertyName()method 
public static function getPropertyName(e:PropertyChangeEvent):String

Digs out property name from the given property change event. if property name starts with Consts.PREFIX_STYLE or Consts.PREFIX_CLIENT, you will get the substring property name without the above prefix string.

Parameters

e:PropertyChangeEvent — a property change event

Returns
String — the dug out property name
getQualifiedClassName()method 
public static function getQualifiedClassName(object:Object):String

Get qualified class name of specified object.

Parameters

object:Object — the object to be checked.

Returns
String — the qualified class name of specified object.
getSubNetwork()method 
public static function getSubNetwork(element:IElement):ISubNetwork

Get the subnetwork element of specified element displaying. The subnetwork will be the most closed ancestor subnetwork.

Parameters

element:IElement — an element to be checked.

Returns
ISubNetwork — the most closed ancester subnetwork element.
getSuperClass()method 
public static function getSuperClass(clazz:Class):Class

Get super class type.

Parameters

clazz:Class — class type.

Returns
Class — super class type.
isPermissionGIS()method 
public static function isPermissionGIS():Boolean

Returns
Boolean
moveElements()method 
public static function moveElements(elements:ICollection, xoffset:Number, yoffset:Number, animate:Boolean = false, finishFunction:Function = null, ui:UIComponent = null):void

Move elements with animate effect.

Parameters

elements:ICollection — elements to be moved.
 
xoffset:Number — x offset of this movement.
 
yoffset:Number — y offset of this movement.
 
animate:Boolean (default = false) — whether move animated.
 
finishFunction:Function (default = null) — a function will be called when movement finished.
 
ui:UIComponent (default = null) — UI component the animation based on.

randomBoolean()method 
public static function randomBoolean():Boolean

Get random boolean value.

Returns
Boolean — a random boolean value.
randomColor()method 
public static function randomColor():Number

Get a random color.

Returns
Number — a random color.
randomInt()method 
public static function randomInt(n:int):int

Get random int less than the specified int number.

Parameters

n:int — the random limit.

Returns
int — a random int number bigger than 0 less than specified limit.
randomNonClearedSeverity()method 
public static function randomNonClearedSeverity():AlarmSeverity

Get a random predefined alarm severity except the cleared severity.

Returns
AlarmSeverity — a random predefined alarm severity except the cleared severity.
randomRange()method 
public static function randomRange(min:Number, max:Number):Number

Get a random number between the specified number range.

Parameters

min:Number — minimum limit
 
max:Number — maximum limit

Returns
Number — a random number between minimum and maximum numbers.
randomSeverity()method 
public static function randomSeverity():AlarmSeverity

Get a random predefined alarm severity.

Returns
AlarmSeverity — a random predefined alarm severity.
registerImageByBitmapData()method 
public static function registerImageByBitmapData(name:String, bitmapData:BitmapData):void

Register a bitmap image resource in TWaver Flex.

Parameters

name:String — the resource name. Use this name to retrieve this resource.
 
bitmapData:BitmapData — the bitmap data of this image resource.

registerImageByClass()method 
public static function registerImageByClass(name:String, imageClass:Class, asComponent:Boolean = false, bounds:Rectangle = null, args:Array = null):void

Register a resource (image, movie clip...) in TWaver Flex by resource class type.

Parameters

name:String — the registered resource name. Use this name to retrieve this resource.
 
imageClass:Class — the resource class type. It can be display object, or image asset.
 
asComponent:Boolean (default = false) — whether this image is registered with a display component.
 
bounds:Rectangle (default = null) — image bound
 
args:Array (default = null) — constructor arguments of image class. Used when new image class by class constructor.

registerImageByDisplayObject()method 
public static function registerImageByDisplayObject(name:String, displayObject:DisplayObject, bounds:Rectangle = null):void

Register a resource (image, movie clip...) in TWaver Flex and embed it in specified display object.

Parameters

name:String — the registered resource name. Use this name to retrieve this resource.
 
displayObject:DisplayObject — a display object embed this resource.
 
bounds:Rectangle (default = null) — bound of this resource.

registerImageByUrl()method 
public static function registerImageByUrl(name:String, url:String):void

Get image resource by url.

Parameters

name:String — the image resource registered name.
 
url:String — the URL address.

registerSmoothingImage()method 
public static function registerSmoothingImage(name:String, imageClass:Class, bounds:Rectangle = null, args:Array = null):void

Register a resource (image, movie clip...) in TWaver Flex with scale-smoothing effect.

Parameters

name:String — the registered resource name. Use this name to retrieve this resource.
 
imageClass:Class — the resource class type. It can be display object, or image asset.
 
bounds:Rectangle (default = null) — resource bounds
 
args:Array (default = null) — constructor arguments of image class. Used when new image class by class constructor.

toDegrees()method 
public static function toDegrees(radian:Number):Number

Change specified angle from radian to degree.

Parameters

radian:Number — angle value in radian

Returns
Number — angle value in degree
toHexString()method 
public static function toHexString(object:Object):String

Get a hex string format of specified number object.

Parameters

object:Object — a number object

Returns
String — hex format of this number object.
toRadians()method 
public static function toRadians(degree:Number):Number

Change specified angle from degree to radian.

Parameters

degree:Number — angle value in degree

Returns
Number — angle value in radian
validateLicense()method 
public static function validateLicense(license:*):Boolean

Validate TWaver Flex license. License is delivered by XML content after purchased TWaver Flex. Input license XML content in to validate TWaver Flex to a licensed software. By default the evaluation version of TWaver Flex will display an evaluation watermark on network and other components. Once the license has been validated, the wartermark will gone.

Parameters

license:* — the license content in XML format or string format.

Returns
Boolean — true if license has been validated, false otherwise.