NetworkNodeSetColor {RNetica}R Documentation

Returns or sets a display colour to use with a Netica node.b

Description

Returns the display colour associated with a node set or sets the node set colour to a specified value. The colour of the node in the Netica GUI will be the colour of the highest priority node set associated with the node (see NetworkSetPriority().

Usage

NetworkNodeSetColor(net, setname, newcolor)

Arguments

net

An active NeticaBN object representing the network.

setname

A character scalar giving the name of the node set to be coloured.

newcolor

An optional scalar of any of the three kind of R colours, i.e., either a colour name (an element of colors()), a hexadecimal string of the form "#rrggbb" or "#rrggbbaa" (see rgb()), or an integer i meaning palette()[i]. Non-string values are coerced to integer. There are two special values: NA is used to indicate that the set should not have a colour associated with it. If newcolor is missing, then the existing colour is returned and not changed.

Details

Netica determines the visual style of a node by stepping through the node sets to which the node belongs in priority order (see NetworkSetPriority()) . Each node set can either have a colour set, or a flag set to indicate that the next node in order or priority should be used to determine the appearance of the node. The expression NetworkNodeSetColor(net,setname,NA) sets the flag so that membership in setname does not affect the display of the node.

The function NetworkNodeSetColor(net,setname,colour) sets the colour associated with the visual display of these nodes (this is only visible when the network is open in the Netica GUI). The colour can be specified in any of the usual ways that colours are specified in R (see col2rgb()). The special value NA is used to indicate that the set should be ‘transparent’, that is the colour of the next set in priority should be used to colour the node.

The function NetworkNodeSetColor(net,setname), with the third argument missing, returns the current node set colour instead of setting it.

Value

The old value of the node colour as hexadecimal string value of the form "#rrggbb".

Note

The colors of the built-in Netica node sets serve as the ultimate default for the display of nodes. These cannot be set or queried through this function. (This is a limitation of the Netica API).

Author(s)

Russell Almond

References

http://norsys.com/onLurl/Manual/index.html: ReorderNodesets_bn(), SetNodesetColor_bn()

See Also

NeticaNode, NodeSets(), NetworkNodeSets(), col2rgb(), rgb(), NetworkNodesInSet(), NetworkSetPriority()

Examples

sess <- NeticaSession()
startSession(sess)

nsnet <- CreateNetwork("NodeSetExample", session=sess)

Ability <- NewContinuousNode(nsnet,"Ability")

X1 <- NewDiscreteNode(nsnet,"Item1",c("Right","Wrong"))
EssayScore <- NewDiscreteNode(nsnet,"EssayScore",paste("level",5:0,sep="_"))

Value <- NewContinuousNode(nsnet,"Value")
NodeKind(Value) <- "Utility"
Placement <- NewDiscreteNode(nsnet,"Placement",
     c("Advanced","Regular","Remedial"))
NodeKind(Placement) <- "Decision"

NodeSets(Ability) <- "ReportingVariable"
NodeSets(X1) <- "Observable"
NodeSets(EssayScore) <- c("ReportingVariable","Observable")

## Default colour is NA (transparent)
stopifnot(
  is.na(NetworkNodeSetColor(nsnet,"Observable"))
)

## Make Reporting variables a pale blue
NetworkNodeSetColor(nsnet,"ReportingVariable",rgb(1,.4,.4))
stopifnot(
  NetworkNodeSetColor(nsnet,"ReportingVariable") == "#ff6666"
)
## Using R (nee X11) color list.
NetworkNodeSetColor(nsnet,"Observable","wheat2")
stopifnot(
  NetworkNodeSetColor(nsnet,"ReportingVariable") == "#ff6666"
)

DeleteNetwork(nsnet)
stopSession(sess)


[Package RNetica version 0.8-2 Index]