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
-
- (Integer) _cached_depth [R/W]Depth cached value. -
- (Integer) _cached_linkThreshold [R/W]linkThreshold cached value. -
- (Integer) _canvasHeight [R/W]Cached height of the view's canvas, set by the displayProperties. -
- (Integer) _canvasWidth [R/W]Cached width of the view's canvas, set by the displayProperties. -
- (Boolean) _displayRefs [R/W]Display references or citations. -
- (String) _foundGuid [R/W]The found GUID. -
- (Integer) _h [R/W]Cached height property from displayProperties. -
- (Integer) _w [R/W]Cached width property from displayProperties. -
- (Integer) _x [R/W]Cached x-axis offset property from displayProperties. -
- (Integer) _y [R/W]Cached y-axis offset property from displayProperties. -
- (String) contentTypeViewing [R/W]The type of content being displayed. -
- (String) defaultTitleKey [R/W]The key for the default title display. -
- (The controller delegate for the node graph.) delegate [R/W] -
- (Integer) depth [R/W]The value for the depth slider. -
- (Object) displayProperties [R/W]This is generally a binding from the delegate. -
- (String) edgeColor [R/W]Edge color. -
- (String) edgeColorSel [R/W]Selected edge color. -
- (Integer) edgeMinWidth [R/W]The minimum width of an edge. -
- (Float) edgeOpacity [R/W]Edge opacity. -
- (Float) edgeOpacitySel [R/W]Selected edge opacity. -
- (String) edgeTextColor [R/W]Edge text color. -
- (Float) 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. -
- (Object) graphTitle [R/W]The title for what is being viewed. -
- (Integer) linkThreshold [R/W]Link stregth threshold. -
- (Integer) metaDataBoxHeightSmall [R/W]Meta data box small height. -
- (Integer) metaDataBoxWidthSmall [R/W]Meta data box small width. -
- (String) metaDataClassName [R/W]Class name for meta data DIV. -
- (Object) metaDataView [R/W]The DOM element that contains the meta data for an item. -
- (String) nodeBorderColor [R/W]Node border color. -
- (String) nodeBorderColorSel [R/W]Selected node border color. -
- (Integer) nodeBorderWidth [R/W]The default width of the node border. -
- (String) nodeColor [R/W]Node background color. -
- (String) nodeColorSel [R/W]Selected node background color. -
- (Integer) nodeDefaultRadius [R/W]Default node size ratio from the size of the screen. -
- (Float) nodeOpacity [R/W]Node opacity. -
- (String) nodeTextColor [R/W]Node text color. -
- (Integer) nodeTextRatio [R/W]The nodeTextRatio allows the font size for the node to the calculated. -
- (Float) nodeXYRatio [R/W]Node x-y ratio The default is x radius is 1.5 times y. -
- (Object) outlets [R/W]Outlets for author stat view. -
- (Boolean) showEdgeLabel [R/W]If set to YES, show the edge label, if NO, hide the label. -
- (Boolean) showEdges [R/W]If NO, don't show edges. -
- (DOM Element) svgCanvas [R/W]"canvas" for the svg tag. -
- (Boolean) useEdgeWeightWidth [R/W]If set to YES, calculate the edge width by looking at the weight of the item, otherwise, skip this operation. -
- (String) viewName [R/W]The name of the view.
- Properties borrowed from class NodeGraph.DragPanMixin:
- _canDrag, _mouseDragTime, _xPos, _yPos
Method Summary
-
- (void) _checkForData(guid, level)Check what data needs to be retrieved. -
- (void) _clearSVG()Clear all SVG elements. -
- (void) _clearSVGElms(has, array, svg)Clear SVG elements selectively. -
- (Array) _createSVGElement(type, attributes, events, kind)Create a new SVG element. -
- (void) _generateDataCoords(guid, level, x, y, delta, theta)Generate the coordinates needed. -
- (void) _hideExistingLines()Hide the lines when redrawing happens. -
- (void) _hideMetaData()Hide meta data box. -
- (void) _render()Collect what needs to be rendered. -
- (void) _renderGraph()Render the SVG. -
- (Boolean) _showMetaData(coordinates, guid)Show meta data for item! -
- (Integer) calcRelationWeight(rel)Given relation object, return weight for it. -
- (Boolean) displayPropertiesDidChange(force)When the displayProperities binding changes, update the view appropriately. -
- (array|SC.Record) findCustomObject(guid)Generate custom metadata for item. -
- (Array) findCustomObjectAttr(object)Find Custom Object Relation Attribute. -
- (String) findCustomObjectLabel(object)Given an object, return its label. -
- (String) getGuidForRelation(rel)Given relation object, return guid for it. -
- (void) init()Initalization function. -
- (void) mouseDown(evt)Save the GUID of the element and invoke delegate if possible. -
- (void) mouseExited(evt)If the mouse leaves the area, hide the meta-data view. -
- (void) mouseMoved(evt)If the mouse is moved on top of the view, see if there is any meta data to show. -
- (void) performCustomRequest(guids, callBack)Get the details of a given item. -
- (void) pinLinesForObj()Pin the lines for object. -
- (Boolean) redrawParamsDidChange()Redraw based on 'content', 'isVisible' binding changes. -
- (String) relationMeetsCustomThreshold(rel)Custom threshold calculation for complex link threshold calculations. -
- (void) setBindingDefaults()Revert bindings to default. -
- (void) setDefaultTitle(content)Set the default title for the view.
- Methods borrowed from class NodeGraph.DragPanMixin:
- handleMouseDownDrag, mouseDragged, mouseUp
Property Details
_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
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'
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 }
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
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
metaDataView [R/W]
The DOM element that contains the meta data for an item.
- Object metaDataView
Discussion
Bound to the '.meta-data?' element.
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
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.
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
showEdgeLabel [R/W]
If set to YES, show the edge label, if NO, hide the label.
- Boolean showEdgeLabel
Default Value: YES
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
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.
_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.
_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.
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.
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.
setDefaultTitle()
Set the default title for the view.
- (void) setDefaultTitle (content)
Parameters
content {Record} Content object used to get the title.