Home Reference Source
public class | source

Molecule

Extends:

Atom → Molecule

Direct Subclass:

GitHubMolecule

This class creates the Molecule atom.

Constructor Summary

Public Constructor
public

constructor(values: object)

The constructor function.

Member Summary

Public Members
public

This atom's type

public

A flag to indicate if this molecule was waiting propagation.

public

The color for the middle dot in the molecule

public

A description of this atom

public

inputs: array

An array of the molecules inputs.

public

This atom's type

public

A list of all of the atoms within this Molecule which should be drawn on the screen as objects.

public

A flag to indicate if this molecule is currently processing.

public

A list of things which should be displayed on the the top level sideBar when in toplevel mode.

public

Deselects Atom

public

A flag to indicate if this molecule should simplify it's output.

public

threshold: float

The threshold for simplification.

public

toProcess: integer

The total number of atoms contained in this molecule which are waiting to process

public

A flag to indicate if this molecule is the top level molecule.

public

totalAtomCount: integer

The total number of atoms contained in this molecule

public

A list of available units.

public

Method Summary

Public Methods
public

Handle a background click (a click which doesn't land on one of the contained molecules) by deselected everything and displaying a 3D rendering of this molecules output.

public

Walks through each of the atoms in this molecule and begins Propagation from them if they have no inputs to wait for

public

Walks through each of the atoms in this molecule and takes a census of how many there are and how many are currently waiting to be processed.

public

changeUnits(newUnitsIndex: *)

public

Set the atom's response to a mouse click up. If the atom is moving this makes it stop moving.

public

copy()

Pushes serialized atoms into array if selected

public

Gives this molecule inputs with the same names as all of it's parent's inputs

public

createSegmentSlider(valueList: *)

Creates segment length slider and passes value to Global Variables

public

deleteNode(backgroundClickAfter: boolean, deletePath: boolean, silent: boolean)

Delete this molecule and everything in it.

public

Unselect this molecule

public

deserialize(json: object, values: object): *

Load the children of this from a JSON representation

public

Creates markdown version of the readme content for this atom in the sidebar

public

Creates a simple BOM list which cannot be edited.

public

Handle double clicks by replacing the molecule currently on the screen with this one, esentially diving into it.

public

draw()

Add the center dot to the molecule

public

Replace the currently displayed molecule with the parent of this molecule...moves the user up one level.

public

loadTree(): *

Triggers the loadTree process from this molecules output

public

async placeAtom(newAtomObj: object, moleculeList: array, typesList: object, unlock: boolean): *

Places a new atom inside the molecule

public

placeConnector(connectorObj: object)

Places a new connector within the molecule

public

Called when this molecules value changes

public

Called when this molecules value changes

public

Reads the path of this molecule's output atom

public

Used to trigger all of the circle atoms within a molecule and all of the molecules within it to update their value.

public

Check to see if any of this molecules children have contributions to make to the README file.

public

Sends the output of this molecule to be displayed in the 3D view.

public

serialize(offset: {"x": number, "y": number}): *

Generates and returns a object representation of this molecule and all of its children.

public

setSimplifyFlag(anEvent: *)

Called when the simplify check box is checked or unchecked.

public

Updates the side bar to display options like 'go to parent' and 'load a different project'.

public

updateValue(targetName: *)

Grab values from the inputs and push them out to the input atoms.

public

waitOnComingInformation(inputName: *)

Sets the atom to wait on coming information.

Inherited Summary

From class Atom
public

[key]: *

Assign each of the values in values as this.value

public

A warning message displayed next to the atom.

public

A function which can be called to cancel the processing being done for this atom.

public

This atom's current color

public

This atom's default color (ie when not selected or processing)

public

A description of this atom

public

inputs: array

An array of all of the input attachment points connected to this atom

public

A flag to indicate if this atom is currently being dragged on the screen.

public

This atom's name

public

This atom's output attachment point if it has one

public

This atom's parent, usually the molecule which contains this atom

public

The path which contains the geometry represented by this atom

public

A flag to indicate if the atom is currently computing a new output.

public

This atom's radius as displayed on the screen is 1/72 width

public

A flag to indicate if this atom is currently selected

public

This atom's color when selected

public

A flag to indicate if we are hovering over this atom.

public

The color currently used for strokes

public

This atom's unique ID. Often overwritten later when loading

public

This atom's value...Is can this be done away with? Are we basically storing the value in the output now?

public

The X cordinate of this atom

public

The Y cordinate of this atom

public

addIO(type: boolean, name: string, target: object, valueType: string, defaultValue: object)

Adds a new attachment point to this atom

public

Calls a worker thread to compute the atom's value.

public

Starts propagation placeholder.

public

census(): number[]

Returns an array of length two indicating that this is one atom and if it is waiting to be computed

public

Clears the alert message attached to this atom.

public

clickDown(x: number, y: number, clickProcessed: boolean): *

Set the atom's response to a mouse click. This usually means selecting the atom and displaying it's contents in 3D

public

Set the atom's response to a mouse click and drag. Moves the atom around the screen.

public

Set the atom's response to a mouse click up. If the atom is moving this makes it stop moving.

public

createButton(list: object, parent: object, buttonText: string, functionToCall: object)

Creates button.

public

createCheckbox(list: object, buttonText: string, -: boolean, functionToCall: object)

Creates button.

public

createDropDown(list: object, parent: object, options: array, selectedOption: number, description: string, Callback: object)

Creates dropdown with multiple options to select.

public

createEditableValueListItem(list: object, object: object, key: string, label: string, resultShouldBeNumber: boolean, callBack: object)

Creates an editable HTML item to set the value of an object element.

public

createFileUpload(list: object, parent: object, buttonText: string, functionToCall: object)

Creates file upload button.

public

Creates a html representation of the passed text.

public

createNonEditableValueListItem(list: object, object: object, key: string, label: string)

Creates an non-editable HTML item to set the value of an object element.

public

Set's the output value and shows the atom output on the 3D view.

public

deleteNode(backgroundClickAfter: boolean, deletePath: boolean, silent: boolean)

Delete this atom.

public

Displays the atom in 3D and sets the output.

public

Set the atom's response to a mouse double click. By default this isn't to do anything other than mark the double click as handled.

public

draw(drawType: *)

Draws the atom on the screen

public

findIOValue(ioName: string): *

Find the value of an input for with a given name.

public

Generates the path for this atom from it's location in the graph

public

Initialized the sidebar with a title and create the HTML object.

public

Set the atom's response to a key press. Is used to delete the atom if it is selected.

public

loadTree(): *

Sets all the input and output values to match their associated atoms.

public

removeIO(type: boolean, name: string, target: object, silent: object)

Removes an attachment point from an atom.

public

requestReadme(): *[]

Return any contribution from this atom to the README file

public

selectBox(x: *, y: *, xEnd: *, yEnd: *)

Delineates bounds for selection box.

public

Send the value of this atom to the 3D display.

public

serialize(offset: {"x": number, "y": number}): *

Create an object containing the information about this atom that we want to save.

public

setAlert(message: string)

Set an alert to display next to the atom.

public

setValues(values: object)

Applies each of the passed values to this as this.x

public

update()

Runs with each frame to draw the atom.

public

Updates the side bar to display information about the atom.

public

Token update value function to give each atom one by default

public

Sets the atom to wait on coming information.

public

walkBackForConstants(callback: *)

Used to walk back out the tree generating a list of constants...used for evolve

Public Constructors

public constructor(values: object) source

The constructor function.

Override:

Atom#constructor

Params:

NameTypeAttributeDescription
values object

An array of values passed in which will be assigned to the class as this.x

Public Members

public atomType: string source

This atom's type

public awaitingPropagationFlag: number source

A flag to indicate if this molecule was waiting propagation. If it is it will take place the next time we go up one level.

public centerColor: string source

The color for the middle dot in the molecule

public description: string source

A description of this atom

Override:

Atom#description

public inputs: array source

An array of the molecules inputs. Is this not inherited from atom?

Override:

Atom#inputs

public name: string source

This atom's type

Override:

Atom#name

public nodesOnTheScreen: array source

A list of all of the atoms within this Molecule which should be drawn on the screen as objects.

public processing: boolean source

A flag to indicate if this molecule is currently processing.

Override:

Atom#processing

public runModeSidebarAdditions: array source

A list of things which should be displayed on the the top level sideBar when in toplevel mode.

public selected: boolean source

Deselects Atom

Override:

Atom#selected

public simplify: boolean source

A flag to indicate if this molecule should simplify it's output.

public threshold: float source

The threshold for simplification. This is the maximum fraction of vertices which will be removed.

public toProcess: integer source

The total number of atoms contained in this molecule which are waiting to process

public topLevel: boolean source

A flag to indicate if this molecule is the top level molecule.

public totalAtomCount: integer source

The total number of atoms contained in this molecule

public units: object source

A list of available units.

public unitsIndex: number source

Public Methods

public backgroundClick() source

Handle a background click (a click which doesn't land on one of the contained molecules) by deselected everything and displaying a 3D rendering of this molecules output.

public beginPropagation(force: boolean) source

Walks through each of the atoms in this molecule and begins Propagation from them if they have no inputs to wait for

Override:

Atom#beginPropagation

Params:

NameTypeAttributeDescription
force boolean
  • optional
  • default: false

public census(): undefined[] source

Walks through each of the atoms in this molecule and takes a census of how many there are and how many are currently waiting to be processed.

Override:

Atom#census

Return:

undefined[]

public changeUnits(newUnitsIndex: *) source

Params:

NameTypeAttributeDescription
newUnitsIndex *

public clickUp(x: number, y: number) source

Set the atom's response to a mouse click up. If the atom is moving this makes it stop moving.

Override:

Atom#clickUp

Params:

NameTypeAttributeDescription
x number

The X coordinate of the click

y number

The Y coordinate of the click

public copy() source

Pushes serialized atoms into array if selected

public copyInputsFromParent() source

Gives this molecule inputs with the same names as all of it's parent's inputs

public createSegmentSlider(valueList: *) source

Creates segment length slider and passes value to Global Variables

Params:

NameTypeAttributeDescription
valueList *

public deleteNode(backgroundClickAfter: boolean, deletePath: boolean, silent: boolean) source

Delete this molecule and everything in it.

Override:

Atom#deleteNode

Params:

NameTypeAttributeDescription
backgroundClickAfter boolean
  • optional
  • default: true
deletePath boolean
  • optional
  • default: true
silent boolean
  • optional
  • default: false

public deselect() source

Unselect this molecule

public deserialize(json: object, values: object): * source

Load the children of this from a JSON representation

Params:

NameTypeAttributeDescription
json object

A json representation of the molecule

values object

An array of values to apply to this molecule before de-serializing it's contents. Used by githubmolecules to set top level correctly

Return:

*

public displaySidebarReadme(list: object) source

Creates markdown version of the readme content for this atom in the sidebar

Params:

NameTypeAttributeDescription
list object

The HTML object to append the created element to.

public displaySimpleBOM(list: object) source

Creates a simple BOM list which cannot be edited. The generated element is added to the passed list.

Params:

NameTypeAttributeDescription
list object

The HTML object to append the created element to.

public doubleClick(x: number, y: number): * source

Handle double clicks by replacing the molecule currently on the screen with this one, esentially diving into it.

Override:

Atom#doubleClick

Params:

NameTypeAttributeDescription
x number

The x coordinate of the click

y number

The y coordinate of the click

Return:

*

public draw() source

Add the center dot to the molecule

Override:

Atom#draw

public goToParentMolecule() source

Replace the currently displayed molecule with the parent of this molecule...moves the user up one level.

public loadTree(): * source

Triggers the loadTree process from this molecules output

Override:

Atom#loadTree

Return:

*

public async placeAtom(newAtomObj: object, moleculeList: array, typesList: object, unlock: boolean): * source

Places a new atom inside the molecule

Params:

NameTypeAttributeDescription
newAtomObj object

An object defining the new atom to be placed

moleculeList array

Only passed if we are placing an instance of Molecule.

typesList object

A dictionary of all of the available types with references to their constructors

unlock boolean

A flag to indicate if this atom should spawn in the unlocked state.

Return:

*

public placeConnector(connectorObj: object) source

Places a new connector within the molecule

Params:

NameTypeAttributeDescription
connectorObj object

An object representation of the connector specifying its inputs and outputs.

public propagate() source

Called when this molecules value changes

public pushPropagation() source

Called when this molecules value changes

public readOutputAtomPath(): * source

Reads the path of this molecule's output atom

Return:

*

public refreshCircles() source

Used to trigger all of the circle atoms within a molecule and all of the molecules within it to update their value. Used when the number of segments changes.

public requestReadme(): * source

Check to see if any of this molecules children have contributions to make to the README file. Children closer to the top left will be applied first. TODO: No contribution should be made if it's just a title.

Override:

Atom#requestReadme

Return:

*

public sendToRender() source

Sends the output of this molecule to be displayed in the 3D view.

Override:

Atom#sendToRender

public serialize(offset: {"x": number, "y": number}): * source

Generates and returns a object representation of this molecule and all of its children.

Override:

Atom#serialize

Params:

NameTypeAttributeDescription
offset {"x": number, "y": number}
  • optional
  • default: {"x":0,"y":0}

Return:

*

public setSimplifyFlag(anEvent: *) source

Called when the simplify check box is checked or unchecked.

Params:

NameTypeAttributeDescription
anEvent *

public updateSidebar(): * source

Updates the side bar to display options like 'go to parent' and 'load a different project'. What is displayed depends on if this atom is the top level, and if we are using run mode.

Override:

Atom#updateSidebar

Return:

*

public updateValue(targetName: *) source

Grab values from the inputs and push them out to the input atoms.

Override:

Atom#updateValue

Params:

NameTypeAttributeDescription
targetName *

public waitOnComingInformation(inputName: *) source

Sets the atom to wait on coming information. Basically a pass through, but used for molecules

Override:

Atom#waitOnComingInformation

Params:

NameTypeAttributeDescription
inputName *