dojox/drawing/util/common (version 1.10)

Summary

A collection of common methods used for DojoX Drawing. This singleton is accessible in most Drawing classes as this.util

Property Summary

Method Summary

  • abbr(type) Converts a namespace (typically a tool or a stencil) into an abbreviation
  • angle(obj,snap) Return angle based on mouse object
  • argsToObj() Attempts to determine in a Mouse Object was passed or indiviual numbers.
  • attr(elem,prop,value,squelchErrors) Helper function to attach attributes to SVG and VML raw nodes.
  • byId(id) Get an object that was registered with util.register
  • constrainAngle(obj,min,max) Ensures the angle in the Mouse Object is within the min and max limits.
  • degToRad(n) Convert the passed number to radians.
  • distance() Return the length derived from the coordinates in the Mouse object.
  • idSetStart(num)
  • length(o) Return the length derived from the coordinates in the Mouse object.
  • lineSub(x1,y1,x2,y2,amt) Subtract an amount from a line
  • mixin(o1,o2)
  • oppAngle(ang)
  • pointOnCircle(cx,cy,radius,angle) A very helpful method.
  • radians(o) Return the radians derived from the coordinates in the Mouse object.
  • radToDeg(n) Convert the passed number to degrees.
  • register(obj) Since util is the only Singleton in Drawing (besides keys) it is used to help connect the Drawing object the Toolbar.
  • slope(p1,p2) Given two poits of a line, returns the slope.
  • snapAngle(obj,ca) Snaps a line to the nearest angle
  • uid(str) Creates a unique ID.

Properties

objects

Methods

abbr(type)

Converts a namespace (typically a tool or a stencil) into an abbreviation

Parameter Type Description
type undefined
Returns:number
angle(obj,snap)

Return angle based on mouse object

Parameter Type Description
obj EventObject

Manager.Mouse event.

snap Float
Optional

Returns nearest angle within snap limits

Returns:undefined
argsToObj()

Attempts to determine in a Mouse Object was passed or indiviual numbers. Returns an object.

Returns:undefined | object
attr(elem,prop,value,squelchErrors)

Helper function to attach attributes to SVG and VML raw nodes.

Parameter Type Description
elem Object
prop property
value ? value
squelchErrors undefined
Returns:boolean | undefined
byId(id)

Get an object that was registered with util.register

Parameter Type Description
id String
Returns:undefined
constrainAngle(obj,min,max)

Ensures the angle in the Mouse Object is within the min and max limits. If not one of those limits is used. Returns an x,y point for the angle used.

Parameter Type Description
obj EventObject
min Number
max Number
Returns:EventObject | undefined
degToRad(n)

Convert the passed number to radians.

Parameter Type Description
n Number
Returns:number
distance()

Return the length derived from the coordinates in the Mouse object. Different from util.length in that this always returns an absolute value.

Returns:undefined
idSetStart(num)
Parameter Type Description
num undefined
length(o)

Return the length derived from the coordinates in the Mouse object.

Parameter Type Description
o EventObject
Returns:undefined
lineSub(x1,y1,x2,y2,amt)

Subtract an amount from a line

x1,y1,x2,y2 represents the Line. 'amt' represents the amount to subtract from it.

Parameter Type Description
x1 Number
y1 Number
x2 Number
y2 Number
amt Number
Returns:object
mixin(o1,o2)
Parameter Type Description
o1 undefined
o2 undefined
oppAngle(ang)
Parameter Type Description
ang Angle
Returns:Angle
pointOnCircle(cx,cy,radius,angle)

A very helpful method. If you know the center (or starting) point, length and angle, find the x,y point at the end of that line.

Parameter Type Description
cx Number
cy Number
radius Number
angle Number
Returns:object
radians(o)

Return the radians derived from the coordinates in the Mouse object.

Parameter Type Description
o EventObject
Returns:undefined
radToDeg(n)

Convert the passed number to degrees.

Parameter Type Description
n Number
Returns:number
register(obj)

Since util is the only Singleton in Drawing (besides keys) it is used to help connect the Drawing object the Toolbar. Since multiple drawings can be on one page, this function serves a little more use than on first apearance.

Parameter Type Description
obj Object
slope(p1,p2)

Given two poits of a line, returns the slope.

Parameter Type Description
p1 Object
p2 Object
Returns:number
snapAngle(obj,ca)

Snaps a line to the nearest angle

Parameter Type Description
obj EventObject
ca Float

A decimal number fraction of a half circle.

  • .5 would snap to 90 degrees
  • .25 would snap to 45 degrees
  • .125 would snap to 22.5 degrees, etc.
Returns:undefined
uid(str)

Creates a unique ID.

Parameter Type Description
str String
Optional

If provided, kept in a map, incremented and used in the id. Otherwise 'shape' is used.

Returns:string
Error in the documentation? Can’t find what you are looking for? Let us know!