Class NodeGraph.NodeGraphView

Extends: NodeGraph.DragPanMixin, SC.View
Defined in: frameworks/nodegraph/views/nodegraph.js
Version: 1.0
Copyright: 2008-2009 Peter Bergström.

Overview

NodeGraph.NodeGraphView

This is the node graph view. This will be extended by various views to show a node-edge graph It will show all nodes for an centered object and also link between them. Strong relationships will be shown with thicker and darker lines. This view uses SVG.

Constants defined in core.js:

var NODE = 0; var EDGE = 1; var TEXT = 2; var EDGETEXT = 4; var REL = 3; var NODEGRAPH_DEFAULT_SCALE = 10; var NODEGRAPH_USE_CHILDREN_OFFSET = YES; var NODEGRAPH_OFFSET_PERCENT = .40;

Property Summary

Properties borrowed from class NodeGraph.DragPanMixin:
_canDrag, _mouseDragTime, _xPos, _yPos

Method Summary

Methods borrowed from class NodeGraph.DragPanMixin:
handleMouseDownDrag, mouseDragged, mouseUp

Property Details

_cached_depth [R/W]

Depth cached value.

-   Integer _cached_depth

Default Value: 2


_cached_linkThreshold [R/W]

linkThreshold cached value.

-   Integer _cached_linkThreshold

Default Value: 0


_canvasHeight [R/W]

Cached height of the view's canvas, set by the displayProperties.

-   Integer _canvasHeight

Default Value: 600px


_canvasWidth [R/W]

Cached width of the view's canvas, set by the displayProperties.

-   Integer _canvasWidth

Default Value: 800px


_displayRefs [R/W]

Display references or citations.

-   Boolean _displayRefs

Default Value: YES


_foundGuid [R/W]

The found GUID.

-   String _foundGuid


_h [R/W]

Cached height property from displayProperties.

-   Integer _h


_w [R/W]

Cached width property from displayProperties.

-   Integer _w


_x [R/W]

Cached x-axis offset property from displayProperties.

-   Integer _x


_y [R/W]

Cached y-axis offset property from displayProperties.

-   Integer _y


contentTypeViewing [R/W]

The type of content being displayed.

-   String contentTypeViewing

Default Value: 'Paper'


defaultTitleKey [R/W]

The key for the default title display.

-   String defaultTitleKey

Default Value: 'title'


delegate [R/W]

-   The controller delegate for the node graph. delegate


depth [R/W]

The value for the depth slider.

-   Integer depth


displayProperties [R/W]

This is generally a binding from the delegate.

-   Object displayProperties

Discussion

To set up to the binding, do the following:

displayPropertiesBinding: 'Path.to.delegate.displayProperties'

Values { height: 0, width: 0, left: 0, top: 0, zoomValue: 0, portalWidth: 0, portalHeight: 0 }


edgeColor [R/W]

Edge color.

-   String edgeColor

Default Value: '#333'


edgeColorSel [R/W]

Selected edge color.

-   String edgeColorSel

Default Value: 'red'


edgeMinWidth [R/W]

The minimum width of an edge.

-   Integer edgeMinWidth

Default Value: 1px


edgeOpacity [R/W]

Edge opacity.

-   Float edgeOpacity

Default Value: 0.2


edgeOpacitySel [R/W]

Selected edge opacity.

-   Float edgeOpacitySel

Default Value: 0.5


edgeTextColor [R/W]

Edge text color.

-   String edgeTextColor

Default Value: '#666'


edgeTextPosOffset [R/W]

A value of 0.1 would puts the edge label close to start node, 0.5 would put it in the middle of the edge, 0.9 would put it close to the end node.

-   Float edgeTextPosOffset

Default Value: 0.3

Discussion

graphTitle [R/W]

The title for what is being viewed.

-   Object graphTitle


linkThreshold [R/W]

Link stregth threshold.

-   Integer linkThreshold

Default Value: 0

Discussion

Override this.


metaDataBoxHeightSmall [R/W]

Meta data box small height.

-   Integer metaDataBoxHeightSmall

Default Value: 100px


metaDataBoxWidthSmall [R/W]

Meta data box small width.

-   Integer metaDataBoxWidthSmall

Default Value: 200px


metaDataClassName [R/W]

Class name for meta data DIV.

-   String metaDataClassName

Default Value: ''


metaDataView [R/W]

The DOM element that contains the meta data for an item.

-   Object metaDataView

Discussion

Bound to the '.meta-data?' element.


nodeBorderColor [R/W]

Node border color.

-   String nodeBorderColor

Default Value: '#EAA400'


nodeBorderColorSel [R/W]

Selected node border color.

-   String nodeBorderColorSel

Default Value: '#FFB60B'


nodeBorderWidth [R/W]

The default width of the node border.

-   Integer nodeBorderWidth

Default Value: 1px


nodeColor [R/W]

Node background color.

-   String nodeColor

Default Value: '#FFCB2F'


nodeColorSel [R/W]

Selected node background color.

-   String nodeColorSel

Default Value: 'yellow'


nodeDefaultRadius [R/W]

Default node size ratio from the size of the screen.

-   Integer nodeDefaultRadius

Default Value: 25

Discussion

Default is 25 times smaller than height.


nodeOpacity [R/W]

Node opacity.

-   Float nodeOpacity

Default Value: 1


nodeTextColor [R/W]

Node text color.

-   String nodeTextColor

Default Value: '#666'


nodeTextRatio [R/W]

The nodeTextRatio allows the font size for the node to the calculated.

-   Integer nodeTextRatio

Default Value: 2

Discussion

The font size is calculated as radius/nodeTextRatio.


nodeXYRatio [R/W]

Node x-y ratio The default is x radius is 1.5 times y.

-   Float nodeXYRatio

Default Value: 1.5

Discussion

outlets [R/W]

Outlets for author stat view.

-   Object outlets


showEdgeLabel [R/W]

If set to YES, show the edge label, if NO, hide the label.

-   Boolean showEdgeLabel

Default Value: YES


showEdges [R/W]

If NO, don't show edges.

-   Boolean showEdges

Default Value: YES


svgCanvas [R/W]

"canvas" for the svg tag.

-   DOM Element svgCanvas


useEdgeWeightWidth [R/W]

If set to YES, calculate the edge width by looking at the weight of the item, otherwise, skip this operation.

-   Boolean useEdgeWeightWidth

Default Value: YES


viewName [R/W]

The name of the view.

-   String viewName

Default Value: 'none'


Method Detail

_checkForData()

Check what data needs to be retrieved.

-   (void) _checkForData (guid, level)

Parameters

guid {string} The guid of the item.

level {Integer} The current level.


_clearSVG()

Clear all SVG elements.

-   (void) _clearSVG ()


_clearSVGElms()

Clear SVG elements selectively.

-   (void) _clearSVGElms (has, array, svg)

Parameters

has {Object} The old DOM node cache.

array {Array} The array of currently rendered DOM nodes.

(DOM Element)svg The DOM element to attach to.


_createSVGElement()

Create a new SVG element.

-   (Array) _createSVGElement (type, attributes, events, kind)

Parameters

type {string} The node type.

attributes {Object} The attributes hash.

events {Object} The events hash.

kind {Integer} Flag that specifies what SVG element to attach the element to.

Returns

(Array) {DOM Element} The SVG element that was created.


_generateDataCoords()

Generate the coordinates needed.

-   (void) _generateDataCoords (guid, level, x, y, delta, theta)

Parameters

guid {string} The guid of the item.

level {Integer} The current level.

x {Integer} The x coordinate in pixels.

y {Integer} The y coordinate in pixels.

delta {Integer} The delta in degrees.

theta {Integer} The delta in theta.


_hideExistingLines()

Hide the lines when redrawing happens.

-   (void) _hideExistingLines ()


_hideMetaData()

Hide meta data box.

-   (void) _hideMetaData ()


_render()

Collect what needs to be rendered.

-   (void) _render ()

Discussion

Then render the view.


_renderGraph()

Render the SVG.

-   (void) _renderGraph ()


_showMetaData()

Show meta data for item!

-   (Boolean) _showMetaData (coordinates, guid)

Parameters

coordinates {Object} The x,y coordinates of the mouse pointer.

guid {string} The guid of the item.

Returns

(Boolean) Returns NO if there are no coordinates or content.


calcRelationWeight()

Given relation object, return weight for it.

-   (Integer) calcRelationWeight (rel)

Parameters

rel {Object} The relation object or array.

Returns

(Integer) Returns the calculated weight for the relation object.


displayPropertiesDidChange()

When the displayProperities binding changes, update the view appropriately.

-   (Boolean) displayPropertiesDidChange (force)

Parameters

force {boolean} If YES, force a redraw.

Returns

(Boolean) Returns NO if there is no guid of if the view is not visible.

Observes

displayProperties

depth

linkThreshold


findCustomObject()

Generate custom metadata for item.

-   (array|SC.Record) findCustomObject (guid)

Parameters

guid {string} The guid for content object that is found in the SC Store.

Returns

(array|SC.Record) Returns the found content object.


findCustomObjectAttr()

Find Custom Object Relation Attribute.

-   (Array) findCustomObjectAttr (object)

Parameters

object {Record} The content object.

Returns

(Array) Returns the found relation attribute array.


findCustomObjectLabel()

Given an object, return its label.

-   (String) findCustomObjectLabel (object)

Parameters

object {Object} The content object.

Returns

(String) Returns a title string for display.


getGuidForRelation()

Given relation object, return guid for it.

-   (String) getGuidForRelation (rel)

Parameters

rel {Object} The relation object or array.

Returns

(String) Returns the guid for the relation object.


init()

Initalization function.

-   (void) init ()

Discussion

Set up the SVG DOM Nodes.


mouseDown()

Save the GUID of the element and invoke delegate if possible.

-   (void) mouseDown (evt)

Parameters

(DOM Event)evt The mouseDown event.


mouseExited()

If the mouse leaves the area, hide the meta-data view.

-   (void) mouseExited (evt)

Parameters

(DOM Event)evt The mouseExited event.


mouseMoved()

If the mouse is moved on top of the view, see if there is any meta data to show.

-   (void) mouseMoved (evt)

Parameters

(DOM Event)evt The mouseMoved event.


performCustomRequest()

Get the details of a given item.

-   (void) performCustomRequest (guids, callBack)

Parameters

guids {Array} The array of guids.

callBack {Function} The callBack function is called when the request is successful.


pinLinesForObj()

Pin the lines for object.

-   (void) pinLinesForObj ()


redrawParamsDidChange()

Redraw based on 'content', 'isVisible' binding changes.

-   (Boolean) redrawParamsDidChange ()

Returns

(Boolean) Returns NO if there is no guid of if the view is not visible.

Observes

content

isVisible


relationMeetsCustomThreshold()

Custom threshold calculation for complex link threshold calculations.

-   (String) relationMeetsCustomThreshold (rel)

Parameters

rel {Object} The relation's guid.

Returns

(String) Returns if the item is accepted by the threshold(s). Returns NO otherwise.


setBindingDefaults()

Revert bindings to default.

-   (void) setBindingDefaults ()


setDefaultTitle()

Set the default title for the view.

-   (void) setDefaultTitle (content)

Parameters

content {Record} Content object used to get the title.


Documentation generated by JsDoc Toolkit 2.0.2 on Mon Nov 23 2009 23:08:05 GMT-0800 (PST)