dummyDevice {unknown}R Documentation

Create a degenerate collection of R-level graphics device functions.

Description

This function creates a collection of functions that can be used to implement an R-level graphics device. These functions don't do much other than, by default, announce they have been called by printing the name of the corresponding graphics primitive (e.g. activate, line, circle). The action can be customized using the bodies parameter.

We use this to a) test the functionality of the package, and b) to provide a basic skeleton of a device which programmers can override and customize by providing replacements for particular graphical primitive operations. In other words, we can obtain the dummy device object and then set any of its slots to provide our own implementation.

This function does not create the graphics device (see graphicsDevice) but rather an object that is used to represent the R functions that an R-level graphics device will be given when it is instantiated.

The default size function sets the value of the right and bottom to those in the device.

Some of the graphical primitive functions are expected to return a value. These functions do not and so warnings about coercion generating NA values may occur when you use these. These are not fatal.

Usage

dummyDevice(..., bodies = makeBodies(), sample = simpleFun())

Arguments

... name = function pairs that specify our own implementations of particular graphical operations.
bodies a list giving the bodies.
sample a sample function that is copied and its body modified.

Value

An object of class RDevDescMethods-class.

Author(s)

Duncan Temple Lang

References

“The R Internals Manual”, R Development Core Team.

See Also

graphicsDevice

Examples

  funs = dummyDevice()
  dev = graphicsDevice(funs)
  .Devices

      # to call browser in each function. This will get very tedious.
  funs = dummyDevice( bodies = RGraphicsDevice:::makeBodies(quote(browser())))
## Not run: 
  dev = graphicsDevice(funs)
## End(Not run)

  funs = dummyDevice(activate = function(dev) { dev$right = 1000; dev$bottom = 600})
  dev = graphicsDevice(funs)

  funs = dummyDevice(line = function(x1, y1, x2, y2, gcontext, dev) browser() )
  dev = graphicsDevice(funs)

  funs = dummyDevice()
  funs@activate = function(dev) { dev$right = 1000; dev$bottom = 600}
  dev = graphicsDevice(funs)

[Package Index]