Desktop

Simplicite.Diagram. Desktop

new Desktop(p)

Description:
  • Desktop with SVG

Parameters:
Name Type Description
p Object

options

Properties
Name Type Description
x number

Origin position x

y number

Origin position y

zoom number

Zoom factor

color string

Background color

grid number

Grid size or 0 to hide

Methods

addDef()

Description:
  • Add definition to SVG

addDefIcon()

Description:
  • Add base64 icon to defs: inlined image for standalone usage (export to image, svg+xml...)

addDefImage()

Description:
  • Add base64 image to defs: inlined image for standalone usage (export to image, svg+xml...)

addDefImageFont()

Description:
  • Convert font icon to PNG definition

Description:
  • Add a link on desktop

Parameters:
Name Type Description
data Object

{ fromObject, fromId, toObject, toId, object, id }

addNode(data)

Description:
  • Add a node in diagram

Parameters:
Name Type Description
data Object

node data

addNote(data)

Description:
  • Add a note in diagram

Parameters:
Name Type Description
data Object

note data { x,y,w,h,text }

applyToNodes()

Description:
  • Apply a function on (selected) nodes

bringToLayer(x, front)

Description:
  • Brings element to front/back of its layer

Parameters:
Name Type Description
x Object

Node/Container

front boolean

true to bring to front, false to back

ensureVisible()

Description:
  • Ensure absolute div to be visible on desk

getContainer(item)

Description:
  • Search a container in diagram if exists

Parameters:
Name Type Description
item Object

filter { object, id }

getContent(options, cbk)

Description:
  • Get the SVG content as text

Parameters:
Name Type Description
options Object
Properties
Name Type Description
clear boolean

true to clear dimension, unused image...

zoom number

optional scale 1=100%

grid number

0=none

cbk function

callback(svg content)

getDefIcon()

Description:
  • Get defined icon

getDefImage()

Description:
  • Get defined image

getImage(format, zoom, cbk)

Description:
  • Convert to image

Parameters:
Name Type Description
format string

optional format (png...), default return SVG image

zoom number

optional scale

cbk function

callback to return the formatted image

Description:
  • Search a link on desktop

Parameters:
Name Type Description
data Object

filters { fromObject, fromId, toObject, toId, object, id, keys }

Description:
  • Get all links on desktop

getNode(item)

Description:
  • Search a node in diagram if exists

Parameters:
Name Type Description
item Object

filter { object, id }

getNodeContent(item)

Description:
  • Search a content item in diagram if exists

Parameters:
Name Type Description
item Object

content { object, id }

getNodeWithContent(item)

Description:
  • Search a node with content in diagram if exists

Parameters:
Name Type Description
item Object

content { object, id }

getNodes(selector)

Description:
  • Get all nodes in diagram

Parameters:
Name Type Description
selector string

optional selector

getNote(id)

Description:
  • Search a note in diagram if exists

Parameters:
Name Type Description
id string

note id

getSelectedNodes(notes)

Description:
  • Get selected nodes in diagram

Parameters:
Name Type Description
notes boolean

include notes ?

hasChanged(b)

Description:
  • Content has changed ?

Parameters:
Name Type Description
b boolean

optional flag

img2base64(src, format, w, h, cbk)

Description:
  • Load image and convert to data URL

Parameters:
Name Type Description
src string

image source URL

format string

base64 format (default png)

w number

width: null=preserve original size | 0=maintain aspect ratio | specified size

h number

height: null=preserve original size | 0=maintain aspect ratio | specified size

cbk function

callback(dataURL, width, height)

init(sync, cbk)

Description:
  • Init the desktop with contents, palettes...

Parameters:
Name Type Description
sync boolean

true to synchronize nodes with DB

cbk function

optional callback

linkTemplatePicker()

Description:
  • Popup to ask user to select a link template between nodes

magnetism()

Description:
  • Node/Container magnetism when grid is active

mouseDeskPos()

Description:
  • Mouse position in desktop (or absolute position)

mousePos()

Description:
  • Mouse position in SVG scale

point2svg()

Description:
  • Convert desk point to SVG scale

removeContainer(c, cascad)

Description:
  • Remove container from diagram

Parameters:
Name Type Description
c Object

Simplicite.Diagram.Container

cascad boolean

true to remove contents from diagram

removeDefIcon()

Description:
  • Remove icon definition

removeDefImage()

Description:
  • Remove image definition

Description:
  • Remove a link on desktop

removeNode(n)

Description:
  • Remove node from diagram

Parameters:
Name Type Description
n Object

Simplicite.Diagram.Node

removeNodes(list)

Description:
  • Remove nodes from diagram

Parameters:
Name Type Description
list jQuery

nodes

selectContainer(el, sel, add)

Description:
  • Select a container

Parameters:
Name Type Description
el $

element

sel boolean

true to select

add boolean

add to selection or reset

selectNode(el, sel, add)

Description:
  • Select a node or a note

Parameters:
Name Type Description
el $

element

sel boolean

true to select

add boolean

add to selection or reset

setBackgroundColor()

Description:
  • Change background color

setZoom(zoom, tx, ty)

Description:
  • Change desktop zoom

Parameters:
Name Type Description
zoom number

zoom factor

tx number

optional translated x origin

ty number

optional translated y origin

shapePicker()

Description:
  • Shape selection

showGrid(size)

Description:
  • Display the grid

Parameters:
Name Type Description
size number

Grid size (0 or false = hide)

svg2point()

Description:
  • Convert SVG point to desk