Skip to content

Retina usage

Tobias Paczian edited this page Mar 23, 2018 · 6 revisions

For a hands-on about how to use widgets and renderers in Retina please refer to the widgets and renderers tutorial. This page lists the management functions and their parameters.

Functions

init

Retina.init(params)

Initialized the path variables of Retina. Any path parameter is optional. You can set library_resource which defaults to Retina/js, renderer_resource which defaults to Retina/renderers and widget_resource which defaults to widgets.


load_renderer

Retina.load_renderer(name, synch)

Loads the renderer name from Retina.renderer_resource into memory. If you want to load a renderer from a different path than Retina.renderer_resource, pass an object { 'name': rendererName, 'resource': pathToRenderer }. The function returns a promise that fulfills when the renderer is loaded. At that point the dependencies in Renderer.about.requires are loaded as well. If synch is true, the function will not return a promise but will run synchronously instead. When the renderer is loaded, an instance will be stored in Retina.RendererInstances[name][0] as a reference for new instances.


load_widget

Retina.load_widget(name)

Loads the widget name from Retina.widget_resource into memory. If you want to load a widget from a different path than Retina.widget_resource, pass an object { 'name': widgetName, 'resource': pathToWidget } as name. When the widget is loaded, the dependencies in Widget.setup will be loaded as well and the reference instance Retina.WidgetInstances[name][0] will be created. The function returns a promise that fulfills when the widget is loaded.


load_library

Retina.load_library(name)

Loads the javascript library name from Retina.library_resource. For external libraries on a different host name must be the full URI of the library. Returns a promise that fulfills when the library is loaded.


Properties

RendererInstances

Retina.RendererInstances

An hash where each key represents a renderer type and holds an array of all instances of that renderer. When a renderer is loaded the first index of that array (0) is the reference instance that is extended in the creation of new renderer instances of that type.


WidgetInstances

Retina.WidgetInstances

An hash where each key represents a widget type and holds an array of all instances of that widget. When a widget is loaded the first index of that array (0) is the reference instance that is extended in the creation of new widget instances of that type.


library_resource

Retina.library_resource

A string representing the base path relative to the location of the HTML for javascript libraries to be loaded with the Retina.load_library method. The default value is Retina/js.


renderer_resource

Retina.renderer_resource

A string representing the base path relative to the location of the HTML for renderer files to be loaded with the Retina.load_renderer method. The default value is Retina/renderers.


widget_resource

Retina.widget_resource

A string representing the base path relative to the location of the HTML for widget files to be loaded with the Retina.load_widget method. The default value is widgets.


Renderer

create

Renderer.create(name, settings, replaceIndex)

Creates and instance of a renderer of the type name which is stored in the Retina.RendererInstances[name] array and is returned by the function. The settings are passed to the renderer instance and extend Renderer.about.defaults. If replaceIndex is specified, the renderer instance will replace that index in the Retina.RendererInstances[name] array instead of being appended to the array.


render

Renderer.render()

Renders the renderer into its target using its current Renderer.settings. This function is typically called again when user interactions or a control widget change the settings. The render function should clear its target before redrawing.


settings

Renderer.settings

Object that holds all settings of the renderer instance. These are initialized by Renderer.about.defaults and extended by the settings passed to the Renderer.create function. The settings may be changed during run time by the renderer itself triggered by user interactions or by a controlling widget. The renderer is then typically rendered again with the updated settings using the Renderer.render function.


about

Renderer.about

Object that contains information about the renderer. Properties include name, title, author and version of the renderer. The name must be the same as the file name of the renderer, minus the renderer. prefix and .js suffix. The about section also has the requires property, which is an array of library names that the renderer needs. They will be automatically loaded by Retina when the renderer is loaded. The defaults property is an object of default values that will be available via Renderer.settings in the renderer instance. The defaults will be extended by the settings passed in the Renderer.create function.


exampleData

Renderer.exampleData

Function that returns an example of simple data that the renderer can display.

Widget

create

Widget.create(name, parameters, nodisplay)

Creates an instance of a widget of type name. The parameters should include at least a target which references a DOM element the widget can render into. The instance is stored in the Retina.WidgetInstances[name] array and is returned by the create function. The Widget.display function is called after the instance has been created unless nodisplay is set to true.


display

Widget.display()

Function that implements the flow of a widget.

Clone this wiki locally