Loon supports layering of visuals and groups of visuals. The l_layer function is a generic method.

l_layer(widget, x, ...)

Arguments

widget

widget path as a string or as an object handle

x

object that should be layered

...

additional arguments, often state definition for the basic layering function

Value

layer object handle, layer id

Details

loon's displays that use the main graphics model (i.e. histogram, scatterplot and graph displays) support layering of visual information. The following table lists the layer types and functions for layering on a display.

TypeDescriptionCreator Function
groupa group can be a parent of other layersl_layer_group
polygonone polygonl_layer_polygon
textone text stringl_layer_text
lineone line (i.e. connected line segments)l_layer_line
rectangleone rectanglel_layer_rectangle
ovalone ovall_layer_oval
pointsn points (filled) circlel_layer_points
textsn text stringsl_layer_text
polygonsn polygonsl_layer_polygons
rectanglesn rectanglesl_layer_rectangles
linesn sets of connected line segmentsl_layer_lines

Every layer within a display has a unique id. The visuals of the data in a display present the default layer of that display and has the layer id 'model'. For example, the 'model' layer of a scatterplot display visualizes the scatterplot glyphs. Functions useful to query layers are

FunctionDescription
l_layer_idsList layer ids
l_layer_getTypeGet layer type

Layers are arranged in a tree structure with the tree root having the layer id 'root'. The rendering order of the layers is according to a depth-first traversal of the layer tree. This tree also maintains a label and a visibility flag for each layer. The layer tree, layer ids, layer labels and the visibility of each layer are visualized in the layers inspector. If a layer is set to be invisible then it is not rendered on the display. If a group layer is set to be invisible then all its children are not rendered; however, the visibility flag of the children layers remain unchanged. Relevant functions are:

FunctionDescription
l_layer_getParentGet parent layer id of a layer
l_layer_getChildrenGet children of a group layer
l_layer_indexGet the order index of a layer among its siblings
l_layer_printTreePrint out the layer tree
l_layer_moveMove a layer
l_layer_lowerSwitch the layer place with its sibling to the right
l_layer_raiseSwitch the layer place with its sibling to the left
l_layer_demoteMoves the layer up to be a left sibling of its parent
l_layer_promoteMoves the layer to be a child of its right group layer sibling
l_layer_hideSet the layers visibility flag to FALSE
l_layer_showSet the layers visibility flag to TRUE
l_layer_isVisibleReturn visibility flag of layer
l_layer_layerVisibilityReturns logical value for whether layer is actually seen
l_layer_groupVisibilityReturns all, part or none for expressing which part of the layers children are visible.
l_layer_deleteDelete a layer. If the layer is a group move all its children layers to the layers parent.
l_layer_expungeDelete layer and all its children layer.
l_layer_getLabelGet layer label.
l_layer_relabelChange layer label.
l_layer_bboxGet the bounding box of a layer.

All layers have states that can be queried and modified using the same functions as the ones used for displays (i.e. l_cget, l_configure, `[` and `[<-`). The last group of layer types in the above table have n-dimensional states, where the actual value of n can be different for every layer in a display.

The difference between the model layer and the other layers is that the model layer has a selected state, responds to selection gestures and supports linking.

For more information run: l_help("learn_R_layer")

See also

Examples

# l_layer is a generic method newFoo <- function(x, y, ...) { r <- list(x=x, y=y, ...) class(r) <- 'foo' return(r) } l_layer.foo <- function(widget, x) { x$widget <- widget id <- do.call('l_layer_polygon', x) return(id) } p <- l_plot() obj <- newFoo(x=c(1:6,6:2), y=c(3,1,0,0,1,3,3,5,6,6,5), color='yellow') id <- l_layer(p, obj) l_scaleto_world(p)