Class GrapholscapeAbstract

Hierarchy

Constructors

Properties

_incremental: IIncremental
availableRenderers: RendererStatesEnum[]
container: HTMLElement
displayedNamesManager: default
entityNavigator: default
lifecycle: Lifecycle = ...
on: IonEvent = ...

Register a callback for a given event.

Remarks

Check LifecycleEvent and IonEvent for the full list of events/callbacks types

Param

The event for which register a callback.

Param

Function to call when the specified event occurs

Example

reacting to a node selection

 import { LifecycleEvent } from 'grapholscape'

// ...init grapholscape

grapholscape.on(LifecycleEvent.NodeSelection, (selectedNode) => {
// here you can do whatever you want with selectedNode, like printing its shape
console.log(selectedNode.shape)
})
ontology: Ontology
renderer: Renderer = ...
themesManager: default
widgets: Map<string, HTMLElement> = ...
widgetsInitialStates: WidgetsConfig

Accessors

  • get buttonsTray(): undefined | null | Element
  • The container in which the bottom-right buttons are placed. You can use this container to add your own Buttons if you want to.

    Returns undefined | null | Element

  • get exportFileName(): string
  • Filename for exports. String in the form: "[ontology name]-[diagram name]-v[ontology version]"

    Returns string

  • get uiContainer(): null | Element
  • The container in which Grapholscape places the UI components. You can use this container to add new widgets or dialogs if you want to.

    Returns null | Element

Methods

  • Center the viewport on a single element.

    Remarks

    If you specify a different diagram from the current one, it will be displayed

    Parameters

    • elementId: string

      the element's id (can be a node or an edge)

    • Optional diagramId: number

      the diagram's id (default: the current one)

    • Optional zoom: number

      the level zoom to apply, do not pass it if you don't want zoom to change

    Returns void

  • Center viewport on a single entity occurrence given its IRI

    Parameters

    • iri: string

      the iri of the entity to find and center on

    • Optional diagramId: number

      the diagram containing the entity. If not specified, the first entity occurrence in any diagram will be used.

    • Optional zoom: number

      the level of zoom to apply. If not specified, zoom level won't be changed.

    Returns void

  • Export current diagram and download it as a PNG image.

    Parameters

    Returns void

  • Export current ontology as an RDFGraph. RDFGraph is a JSON serialization of grapholscape's model. Useful to resume a previous state.

    Returns

    RDFGraph representation of this grapholscape instance's model.

    Returns RDFGraph

  • Export current diagram and download it as an SVG.

    Parameters

    Returns void

  • Filter elements on the diagram.

    Remarks

    It will be currently applied only if the user defined callback on the event FilterRequest returns true and if the internal logic allows for the filter to be applied.

    Parameters

    • filter: string | Filter

      the filter to apply, can be an object of type Filter, DefaultFilterKeyEnum or a string representing the unique key of a defined filter

    Returns void

  • Select an element in a diagram.

    Remarks

    If you specify a different diagram from the current one, it will be displayed

    Parameters

    • elementId: string

      the element's id (can be a node or an edge)

    • Optional diagramId: number

      the diagram's id (default: the current one)

    Returns void

  • Center viewport on a single entity occurrence and selects it given its IRI

    Parameters

    • iri: string

      the iri of the entity to find and center on

    • Optional diagramId: number

      the diagram containing the entity. If not specified, the first entity occurrence in any diagram will be used.

    • Optional zoom: number

      the level of zoom to apply. If not specified, zoom level won't be changed.

    Returns void

  • Change the language used for the labels and comments

    Remarks

    The language must be supported by the ontology or the first available language for a given label/comment wil be used as fallback

    Parameters

    • newLanguage: string

      the language to set Language

    Returns void

  • Change the current renderer (Graphol - Lite - Floaty).

    Remarks

    A RendererState is an implementation for the iRenderState interface that changes the way the Renderer performs the main operations on a Diagram such as rendering it and filtering elements in it. The renderer states included in Grapholscape are: GrapholRendererState, LiteRendererState and FloatyRendererState.

    Example

    // Setting the floaty renderer state
    import { FloatyRendererState } from 'grapholscape'

    grapholscape.setRenderer(new FloatyRendererState())

    Parameters

    • newRenderState: iRenderState

      the renderer state instance to set, if you want to reuse these instances it's totally up to you.

    Returns void

  • Apply a given theme

    Parameters

    • themeId: string

      the theme's ID

    Returns void

  • Show a certain diagram by its ID

    Parameters

    • diagramId: number

      the diagram's id to display

    • Optional viewportState: Viewport

      set a custom Viewport, if not set, last one available will be used

    Returns void

  • Unfilter elements on the diagram.

    Remarks

    It will be currently deactivated only if the user defined callback on the event FilterRequest returns true and if the internal logic allows for the filter to be deactivated.

    Parameters

    • filter: string | Filter

      the filter to disable, can be an object of type Filter, DefaultFilterKeyEnum or a string representing the unique key of a defined filter

    Returns void

  • Apply a certain level of zoom

    Parameters

    • value: number

      level of zoom to set

    Returns void

  • Increase the zooom level by a certain amount

    Parameters

    • amount: number

      the amount of zoom to add

    Returns void

  • Decrease the zooom level by a certain amount

    Parameters

    • amount: number

      the amount of zoom to remove

    Returns void