Just as in map-making, we sometimes want more. You may wish to put up a legend, or some explanatory text, perhaps a prominent label saying, i.e.,
makeSimpleGraph ()
(see 'methods' for more information about this built-in RCytoscape utility function).
g = RCytoscape::makeSimpleGraph ()
g = graph::addNode ('info.node', g)
nodeData (g, 'info.node', 'label') = 'information will be written here'
window.title = 'Legend Demo'
cw = new.CytoscapeWindow (window.title, graph=g)
displayGraph (cw)
layoutNetwork (cw, "jgraph-spring")
redraw (cw)
# now set up the appearance of the informational node, using a bunch of 'direct' calls
setNodeShapeDirect (cw, 'info.node', 'rect')
setNodeSizeDirect (cw, 'info.node', 140)
setNodeFontSizeDirect (cw, 'info.node', 32);
setNodeLabelDirect (cw, 'info.node', '')
setNodeColorDirect (cw, 'info.node', '#FFEEFF')
fitContent (cw)
redraw (cw)
# now change and update the message in the information node a few times
for (i in 1:10) {
random.int = as.integer (100 * runif (1))
new.label = paste ('random label', random.int)
setNodeLabelDirect (cw, 'info.node', new.label)
redraw (cw)
system ('sleep 1')
}