GpsGate Server JavaScript API

Graphics  1.0.0

GpsGate Server JavaScript API > Graphics > Franson.Graphics
Search:
 
Filters

static Class Franson.Graphics

namespace

Properties

_helperSurface - private dojox.gfx.Surface

helper surface attached to a hidden DOM node ('__franson_dojox_gfx_helper') used as a shape factory (this will be the same even if you are using multiple surfaces).

smallestAlphaWithEvents - final float

IE specific. this is in practice invisible *but will still catch mouse events in IE* (which alpha=0 doesn't do..) (all other browsers handle a=0)

Methods

_init

private void _init()
assumes the DOM is ready (lazily called from getCreator, thus not exposed in the public API)
Returns: void

calcBounds

(x,y,w,h) calcBounds(shape)
deliberately Not named getBounds since it potentially does a lot of work.. (should be cached) todo: hmm, should the origin of groups be considered bounds extending? make optional? todo: calcBoundingSphere also? (note: radius of "safe" bounding sphere that allows full rotation of shape around any point within the OBB is: 1.5*Vec2.length(Vec2.sub(BB.max, BB.min)) ) todo: needs special case for textShapes(?)
Parameters:
shape <dojox.gfx.Shape>
Returns: (x,y,w,h)

cloneShape

dojox.gfx.Shape cloneShape(shape, [parent=getCreator()])
mostly to rebuild structures top->down to work around IE/VML bugs.. sigh..
Parameters:
shape <dojox.gfx.Shape>
[parent=getCreator()] <dojox.gfx.Group|dojox.gfx.Surface> to help IE you need to supply the final destination here, otherwise it is optional (added to the getCreator() node)
Returns: dojox.gfx.Shape

destroy

void destroy()
destroys the helper surface. Call if you're destroying your last surface (restarting your gfx)
Returns: void

getChildren

dojox.gfx.Shape[] getChildren(shape)
to make all objects look like they have child nodes (interface) (DOM style)
Parameters:
shape <dojox.gfx.Shape>
Returns: dojox.gfx.Shape[]

getCreator

dojox.gfx.Creator getCreator()
returns the global shape factory Very convenient since you can create objects without having access to the surface/creator.
Returns: dojox.gfx.Creator
(actually a gfx.Surface)

getDOMContainer

DOM getDOMContainer(shapeOrSurface)
Parameters:
shapeOrSurface <dojox.gfx.Shape|dojox.gfx.Surface>
Returns: DOM

getMouseSurfacePosition

(x,y) getMouseSurfacePosition(shapeOrSurface, e)
todo: isn't it possible to get this correctly without the ref to the surface/node!? howto extract stable source or target node? (in SVG should be possible to walk e.target.parentNode->..)
Parameters:
shapeOrSurface <dojox.gfx.Shape|dojox.gfx.Surface>
e <Event>
Returns: (x,y)

getPosition

x,y getPosition(shape)
convenience, also handles shapes with no transform set note that this is still the relative position, i.e not the fully evaluated world-position (see getScreenPosition)
Parameters:
shape <dojox.gfx.Shape>
Returns: x,y

getScreenPosition

(x,y) getScreenPosition(shape)
todo: create fromShapeToScreenCoord() and fromScreenToShapeCoord() functions using _realmatrix?
Parameters:
shape <dojox.gfx.Shape>
Returns: (x,y)

getTextBoundingBox

(x, y, w, h) getTextBoundingBox(textShape)
todo: integrate this in calcBounds see dojox.gfx._getTextBox also
Parameters:
textShape <dojox.gfx.Text>
Returns: (x, y, w, h)
untransformed bounding rectangle

hide

void hide(shape)
todo: fix for silverlight
Parameters:
shape <dojox.gfx.Shape>
Returns: void

isHidden

boolean isHidden(shape)
todo: fix for silverlight
Parameters:
shape <dojox.gfx.Shape>
Returns: boolean

levelOrderIter

Iterable[dojox.gfx.Shape] levelOrderIter(shape)
Parameters:
shape <dojox.gfx.Shape>
Returns: Iterable[dojox.gfx.Shape]

normalizeFill

dojo.Color|dojox.gfx.Gradient normalizeFill(fill)
similar to code in dojo.gfx.shape.setFill() note that in contrast to stroke the returned object is not uniform, either a color or a gradient obj is returned
Parameters:
fill <object|string|dojox.gfx.Fill>
Returns: dojo.Color|dojox.gfx.Gradient

normalizeStroke

dojox.gfx.Stroke normalizeStroke(stroke)
similar to code in dojo.gfx.shape.setStroke()
Parameters:
stroke <string|number[]|dojo.Color|dojox.gfx.Stroke>
Returns: dojox.gfx.Stroke

parentIter

Iterable[dojox.gfx.Shape] parentIter(shape)
child->parent traversal see Franson.Iter.leafParentIter
Parameters:
shape <dojox.gfx.Shape>
Returns: Iterable[dojox.gfx.Shape]

postOrderIter

Iterable[dojox.gfx.Shape] postOrderIter(shape)
Parameters:
shape <dojox.gfx.Shape>
Returns: Iterable[dojox.gfx.Shape]

preOrderIter

Iterable[dojox.gfx.Shape] preOrderIter(shape)
Parameters:
shape <dojox.gfx.Shape>
Returns: Iterable[dojox.gfx.Shape]

refreshShape

void refreshShape()
updates the screen representation if the properties of the base-shape has changed. assumes shape is connected at a single level (todo: traverse entire structure? optional?)
Returns: void

setCursor

void setCursor(shape, cursor)
same limitations as setTitle
Parameters:
shape <dojox.gfx.Shape>
cursor <string>
Returns: void

setPosition

void setPosition(shape, pos)
Parameters:
shape <dojox.gfx.Shape>
pos <(x,y)>
Returns: void

setPRS

void setPRS(shape, pos, [rot=0], [scale=1])
set Position, Rotation and Scale (sometimes called TRS (Translation))
Parameters:
shape <dojxo.gfx.Shape>
pos <(x,y)>
[rot=0] <number> radians
[scale=1] <number|(x,y)>
Returns: void

setTitle

void setTitle(shape, title)
note that this is not guaranteed to work/show (similar to html title-attribute), thus allowed to silently fail. todo: works in FF & IE but not in Safari, Chrome or Opera (and will not work in Silverlight or Canvas) todo: implement using a custom mouse-over popup graphics object instead
Parameters:
shape <dojox.gfx.Shape>
title <string>
Returns: void

show

void show(shape)
todo: fix for silverlight
Parameters:
shape <dojox.gfx.Shape>
Returns: void


Copyright © 2009 Franson Technology AB, Sweden. All rights reserved.